Forum Moderators: coopster

Message Too Old, No Replies

session management

session

         

sjen

2:15 am on May 22, 2005 (gmt 0)

10+ Year Member



My session variables seem to only last for the first page after log in, and disappear on subsequent pages. I tried different things, and finally added session_start() to every page. Is this the correct fix, or will this cause problems down the road and impact session time out?

Stormfx

6:44 am on May 22, 2005 (gmt 0)

10+ Year Member



Unless the php.ini file is set to auto sessions, you have to call session_start() on every page.

sjen

2:51 pm on May 22, 2005 (gmt 0)

10+ Year Member



would this impact session time out? i would like the session to time out and force users to re-login after 5 to 10 minutes of inactivity.

thanks.

ergophobe

4:49 pm on May 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



5-10 minutes is awfully fast and could be really annoying. Unless you expect that most people will be accessing from shared computers, I would go with something quite a bit longer.

As for implementation, I usually just set a timer with a session var

$_SESSION['active] = now();

for example and then check that on every page call and redirect to login if the time allowance is exceeded. You can't really count on the session garbage collection to do this on any precise schedule unless you build your own session handlers.