Page 1 of 1

Talk to me about sessions

Posted: 25 Jan 2011, 16:35
by DarkRanger
Someone with experience, please help here.

Basically, I need to log out a user after a certain amount of time, destroy their session, and then direct then to the login page with a message saying "You have been logged out due to inactivity."

The thing with this is: I need to be able to redirect to the login page from anywhere in the site. Should a AJAX request be made and a user was logged out due to inactivity, the whole site must redirect to the login page and not just the AJAX request. Any frames or such should also redirect the whole page to the login page.

Any ideas?

Re: Talk to me about sessions

Posted: 25 Jan 2011, 16:42
by Ron2K
Language?

Re: Talk to me about sessions

Posted: 25 Jan 2011, 17:01
by DarkRanger
O yeah, PHP. Sorry bout that! :)

Re: Talk to me about sessions

Posted: 25 Jan 2011, 23:34
by -Prometheus-
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................

Re: Talk to me about sessions

Posted: 05 Jul 2011, 13:38
by azizarnold
Hi,

I think what you are looking for is within the PHP.ini file. The section you need to adjust is this:

session.cookie_lifetime

When set to 0 it will only end the session when the browser closes. When set to 60 it will keep the session for 60s,etc.

Quote from PHP website: http://www.php.net/manual/en/session.co ... e-lifetime

session.cookie_lifetime integer
session.cookie_lifetime specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0. See also session_get_cookie_params() and session_set_cookie_params().

Note:

The expiration timestamp is set relative to the server time, which is not necessarily the same as the time in the client's browser.