I have a custom built PHP application framework which uses PHP sessions. Everything runs through index.php, and there is a session_start()
call at the top. Each individual page instantiates an 'action' class which returns HTML via the Smarty engine, this is then dumped to the browser right at the end of index.php.
Everything works fine almost all the time, but in one specific case the $_SESSION
variable gets emptied. I'm debugging by doing print_r($_SESSION)
right after session_start()
and again right at the end of index.php.
On the problem page (and only on this page), the $_SESSION
vars are there as expected at the end of the script, however looking at the session storage file in /var/lib/php/sessions
it is empty, and sure enough when loading any other page the first print_r
shows an empty array. So as far as I can tell there should be no PHP code that is emptying $_SESSION
because the final print_r is the last thing it does.
So my question is, what could I have missed? I've cleared out all stray closing ?> tags to avoid extra whitespace, compared the included files with a page that works and can't see anything obviously wrong. And to re-iterate, no code is/should being executed between me dumping the vars and them getting deleted. Can anyone think of anything else that could clear the session variable?