After i reload the page, $_SESSION becomes empty !
Worked fine until there was some server maintenance.
For the sake of the testing, i only have a index.php file with the lines
session_start();
var_dump($_SESSION);
$_SESSION['test'] = 'works';
echo $_SESSION['test']; //displays the 'works' fine
But as soon as i reload the page, ‘test’ becomes undefined, $_SESSION variable is empty.
echo session_id(); // changes every time
Does anyone knows where to look for the problem ?
Is this an apache misconfiguration about write privileges or some problem with cookies ?
Im gladly hear anykind of idea
2
Answers
Check if there is permission to write in session file.
View error log for error if any exist.
By default, PHP sessions cookies are set for the current session. When you refresh, you get a new sessionID because it is a new cookie.
Try extending the lifetime of the session cookie by using the code below and rename “mydomain” 🙂 (this is assuming you are using session cookies: see PHP documentation on this. If you are using something else to manage your sessions, check there)