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.
Ensure you’ve called
session_start(),/etc/php.ini(or system equivalent) has asession.save_pathset (ususally/var/lib/php/session/) and that directory is writable by your web server (on Linux it should bedrwxrwx---) 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