Results 1 to 3 of 3

Thread: Your Session Has Ended!

  1. #1
    Join Date
    Sep 2006

    Question Your Session Has Ended!


    You often see a message that says "You are logged out because your session has ended"

    How do you check (in PHP) that the session has ended?


  2. #2
    Join Date
    Dec 2007
    Auckland, NZ
    if you go to a site that users session and bookmark the site on a page that requires a login then when you close and open your browser the session is lost(it is a cookie that is deleted when the browser closes)
    the best way to check this is say you have $_SESSION['login'] and you set that to true when a user logsin then you can say
    //display pagee
    //You are logged out because your session has ended

  3. #3
    Join Date
    Aug 2004
    You could store a timestamp in the session data, and if it is more than X seconds old when a page is accessed, you could show such a message and have them log in again. Or you could just let PHP's session settings delete the session data when it gets past a certain age, and if a user accesses a page with a session cookie but has no session data, then show that message and have them log in again. (See the session runtime config options, in particular the session.gc_probability, session.gc_divisor and session.gc_maxlifetime settings.)
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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