Session in PHP

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
nithinkk
Forum Commoner
Posts: 55
Joined: Sat Nov 28, 2009 7:57 am

Session in PHP

Post by nithinkk »

Hi , i want to know how to check whether session is expired or not and when the session is expired i want to update the time as logout time in database...if a user closes the browser without signout what to do? i want to update logout time in database...can any one tell me the PHP code to do that ???

Every 10 minutes it must check whether the session is expired and if expired update the signout time
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Session in PHP

Post by flying_circus »

There were some idea's tossed around in your previous thread, but I think I would implement my system as such:

We aren't going to get an accurate logout time, we'll basically have a window of time to work with.
  • When your user logs in and on every subsequent page request, update a timestamp associated with their account.
  • Determine a maximum allowable time for which your user may remain logged in, without activity (example: 14 minutes).
  • If your user tries to access a page after the max allowable time, they will need to re-login.
  • On this login, if there is a time stamp present on their account, move it to another field in your database, such as "last logout".
  • This will give you a logout time that is accurate within 14 minutes of the actual logout event.
I hope I have portrayed my idea clearly.
Post Reply