session timed out for my webpage

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sobha
Forum Commoner
Posts: 56
Joined: Wed Jul 15, 2009 9:08 pm

session timed out for my webpage

Post by sobha »

Hi,

How to do session timed out for my webpage if user does not access my webpage for a particular time interval.I want to display message as Your session has been timed out.Please login to access it.

Regards,
Sobha
izzy4505
Forum Newbie
Posts: 16
Joined: Tue Aug 11, 2009 1:38 pm

Re: session timed out for my webpage

Post by izzy4505 »

You need to keep track of users sessions on the back end in some way. I'd imagine if their session is timing out, then they are authenticated and logged in. Store the session ID as well as last touched date/time on the database with user information. If they hit another page after x minutes, then show them your "time expired" page and log them out.

Some sites will also use a javascript notification as they are approaching their time. My bank uses one with AJAX, so as you approach your time, you get a dialog box saying "Your time is about to expire, click OK to continue." Annoying as hell, but less annoying then getting logged out in the middle of your work.

Of course, you can't rely solely on Javascript methods... this is something that should ultimately be server-side.
Post Reply