Jump to content

Logging users out after they leave the site


Teonynn

Recommended Posts

Hello all - I have what is becoming a perplexing problem. I have a login / logout session-based system, that also writes a cookie to check to see if the user is really who they say they are. When they log in, it sets them to "online"... when they log out the proper way, the site then sets them to "offline". However - many users don't log out the proper way. They just leave the site. What is the best way to forcibly set them to offline after, say, fifteen minutes of inactivity once they've closed all the pages related to the site and the site itself no longer has access to their system to check?

Set a "last used time" for each user in your database (I'm assuming you're using a database) and have a cron job run every 5 minutes to check if each user's "last used time" is within the time limit. If it's not, logout the user and set them offline.

 

Ken

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.