Jump to content

How to expire login if inactive


dhimok

Recommended Posts

im having the same sort of thing......

 

 

http://www.phpfreaks.com/forums/index.php/topic,135061.0.html

 

 

but what i do is use cookies and store the login length. ( in and the out)  so that if somone hasnt logged out within x minutes ,then it defult loggs them out, and stors login length as only 5 minutes, not 20 minutes eg.

 

this "entices" the user to logout correctly

 

 

gd luck

You would either need to have the session data stored in a db with lastactivity as a time field and use a cron job or setup some code to run at the top of a page anytime it is called and check the database session lastactivity and if it is past 20 minutes delete that hash from the DB so the next time the person loads the page check to see if the session still exists if not prompt them to login again.

well thats where it gets complicated.

 

ill be doing this sson with my site, but at the begining of every page you write a page request log to the database.  fields = request_id, user_id, time, page_name

 

what you do is search the records for User_Id = $User_Id, and time.  find the most recent request ( via time )  and say if it was more than 20 minutes ago, then theyre inactive, and do your logout thing.

 

 

its requires almost a new start.  or at least a new version

 

 

 

 

 

 

please note that i may be completely wrong, and there may be a really easy fool proof way of doing it that i dont know if.......

 

either way, good luck.  ill folliw this thred becauase ill be using it soon.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.