I have a domain domain.com and subdomain sub.domain.com Those two domains have different ftp users (user1, user2) belonging to the same group (usergroup) on linux environment. Finally I have the same PHP application that uses sessions on both domains (one is live and other is testing environment).
When I go to domain.com without going first to sub.domain.com, PHP session file is created in default folder /tmp/ with proper permissions 600 and user1:usergroup, when I access sub.domain.com without going first to domain.com, a file is created with permissions 600 and user2:usergroup.
All is great for all browsers but IE (please do not focus on this). What I found out is that when I access sub.domain.com and then try domain.com PHP tries to read the same session file but has no permissions and page is loading indefinitely. Changing ownership of the file to user1 makes domain.com work but prevents sub.domain.com from working.
How to make Apache or PHP create different files for sessions or make them accessible from both domains.
P.S.
Like I said for some weird reason this happens only for IE and the error message from PHP is:
Uncaught PHP Error: session_start() [function.session-start]: open(/tmp/sess_t1…, O_RDWR) failed: Permission denied (13) in file xxx.php on line 46
on line on line 46 is session_start();
Thank you for any advice in this.
I just had this same problem. It appears to be a problem with the way Apache returns session data for IE7 and IE8, but most likely because IE7 and IE8 have an improper way of announcing the domain they’re requesting session data for.
Here’s my scenario:
Running Apache 1.3 with two domains, each has their own account with their own users:
Here is what happens during a normal visit with Firefox/Safari/Chrome:
/tmp/owned by the usermycompanycom./tmp/owned by usernobody.However, here’s what happens during a visit with IE7 and IE8:
/tmp/owned by the usermycompanycom./tmp/owned by the usernobody, Apache tries to return the session file for mycompany.com.mycompanycom, so the web server, running as usernobodycannot access it. Permission is denied.The solution was, as others have suggested, to create a separate directory in
/tmp/to separate the stored session data for support.mycompany.com:I then added the following to an
.htaccessfile in the root web directory for support.mycompany.com:And finally, I removed any existing session data in
/tmp/to ensure the new session path would get used immediately:And that’s it! Now IE7 and IE8 work properly.
I’m fairly certain this problem has to do with how IE7 and IE8 request session data from Apache. They probably first request session data for mycompany.com and THEN request session data for support.mycompany.com, even though the latter was the only doman entered in the address bar.