Reputation: 4934
I've used session vars multiple times in the past, with no problems, but now it's got me...
The $_SESSION
var I am setting is becoming unset every time the PHP script is fired, although it is setting ok for one variable at a time.
if (!isset($_SESSION['badList'])) {
print 'not set - again?';
$_SESSION['badList'][0] = $lineNum;
}
else
{
$_SESSION['badList'][count($_SESSION)] = $lineNum;
}
Here 'not set - again?' fires every time I perform the suitable action, i.e. PHP is not able to find the initial session var. The session cache seems to clear completely when a script is run, which sort of ruins the point of sessions.
What can I do? Many thanks.
Upvotes: 1
Views: 173
Reputation: 17771
Ensure you've called session_start()
, /etc/php.ini
(or system equivalent) has a session.save_path
set (ususally /var/lib/php/session/
) and that directory is writable by your web server (on Linux it should be drwxrwx---
) and that your disk is not full. If your sessions are being written to a remote store (database, memcached etc) make sure you can connect to that with the credentials your app uses (if applicable).
edit: also ensure you are calling session_write_close()
at the end of your request - if you don't then the session data may not be written
Upvotes: 3