Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts

    Session Timeout Help

    Hello all,

    I have had problems with getting Session Timeouts to work the way I think they should in PHP. (PHP5) Please help me obtain the following:

    Note: All pages on my site call a PHP page where i can put the session script I need help creating.

    I want to do the following:
    - Session times out after 1 hours of inactivity. (Not changing pages or running AJAX.)
    - After 5 and a half hours from the first log in, if the user is still active, prompt them to log in again and start thier session timer over winthout clearing thier session data.
    - If they have not logged back in, at the 6 hour mark, thier session is terminated.

    The reasoning for this is the application I am creating is a Web Application which could very well be left open on someones machine for an entire day or longer. So if through the day that are using the application, i want them to be able to restart thier session timer without losing thier session data. However I need it to log them out after 6 hours for security.

    Any help?
    If I'm postin here, I NEED YOUR HELP!!

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You need to store two timestamps: login timestamp, and lastActivity timestamp. Each page includes a function that check lastActivity and logs the user out (destroys the session) if it is more than 1 hour ago, and checks login timestamp and logs the user out if it is more than 6 hours ago. The function then updates the lastActivity timestamp.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •