Cannot write session data to file [duplicate]
Possible Duplicate:
Failed to write session data
I am having a problem with sessions on my server. Is this a server problem or a coding problem? I get this error message:
Warning: Unknown: Failed to write session data (files).
Please verify that the cu开发者_运维百科rrent setting of session.save_path
is correct (/var/php_sessions) in Unknown on line 0
Most likely either the directory /var/php_sessions
does not exist or the php process doesn't have write permissions for it.
What does
$path = '/var/php_sessions';
foreach( array('file_exists', 'is_dir', 'is_readable', 'is_writeable') as $fn ) {
$rc = $fn($path);
echo $fn, ': ', $rc ? 'true' : 'false', "<br />\n";
}
print?
the error message is pretty clear.
PHP cannot write session data into /var/php_sessions directory.
Change this setting to default value
If you have two sites that you are working on on the same server, that could be your issue. For example, I would run into this issue when developing two separate sites on the same shared host.
Site A:
http://sharedaddress.com/~sitea
Site B:
http://sharedaddress.com/~siteb
The problem is that the sessions would be stored based on the permissions for sharedaddress.com
, and not the site I was working on. When I would switch over to the new site, it would be unable to access the session variables, and I would get the permissions error mentioned above.
To solve this issue, I would use the IP address to go there directly (since typically the site was not live yet).
精彩评论