Talk to me about sessions

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Post Reply
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Talk to me about sessions

Post 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?
Image
User avatar
Ron2K
Forum Technical Administrator
Posts: 9050
Joined: 04 Jul 2006, 16:45
Location: Upper Hutt, New Zealand
Contact:

Re: Talk to me about sessions

Post by Ron2K »

Language?
Kia kaha, Kia māia, Kia manawanui.
DarkRanger
Registered User
Posts: 8346
Joined: 10 May 2006, 02:00
Processor: Intel i5-3750
Motherboard: Gigabyte
Graphics card: nVidia GTX 550Ti
Memory: 8GB Jetram
Contact:

Re: Talk to me about sessions

Post by DarkRanger »

O yeah, PHP. Sorry bout that! :)
Image
-Prometheus-
Resident Drama Llama
Posts: 967
Joined: 05 Mar 2008, 02:00
Contact:

Re: Talk to me about sessions

Post by -Prometheus- »

........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
........................................................................................................................................................................................................
BBLounge - Broadband and Technology forum
Please like our facebook page
azizarnold
Registered User
Posts: 2
Joined: 05 Jul 2011, 13:20
Location: Cape Town
Contact:

Re: Talk to me about sessions

Post 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.
Post Reply