> I'm trying to track down some issues with my site, and am trying to decide > if it's a session variable issue. On a random basis, it appears that session > vars are being dumped, deleted, or unset, as the site will break. Queries > based on session vars don't work, session vars not being displayed, etc. > This seems to happen most often after a page has been idle for a couple of > minutes and a refresh is done on the page. > > This is on a hosted site. I have checked the configuration settings with > phpinfo(); and session support is enabled. > > On all pages where I use $_SESSION[<varname>], I have <?php > session_start();?>. This has been double checked. > > 1) Do session vars timeout, or can they be set to timeout after a certain > length of time? > 2) Is there anything other than session_start(); that needs to be done when > using session vars? > 3) What other things can I check for?
Most things are explained well by the online manual, and you should read and re-read the session documentation. That said, I'll also say that the documentation on sessions is not as informative as I'd like it to be, and I still get reports of sessions expiring before they should. Look at the output from echo phpinfo() and check these session configuration options: session.cookie_lifetime -- should be 0, lasts until quitting the browser session.use_cookies -- should be on session.use_trans_sid -- should be on Some things aren't explained very well, like what does "session.gc_maxlifetime" mean? The maximum time before garbage collection to remove session data that hasn't been used? But to minimize the chance of garbage collection on a shared server wrecking your sessions, you can specify a directory for saving session data. Create a directory (on the same level as your directory of publicly-viewable files if you can) and before the 'session_start();' line, do 'session_save_path("../my_sessions_dir");'. Also be aware that circumstances on the client side can mess with session cookies and cause the session to be lost, like using Internet Explorer with Entourage in Mac OS X. -- Lowell Allen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php