Jump to content

PHP SESSIONS AND LOGIN


Divante

Recommended Posts

I have simple website that uses sessions to update user login information as per the database gets updated when they login and also when they logout. Everything works fine until they close the browser window. The database does not get updated so on the admin side it still shows that they are logged in. What i am tryin to accomplish is to detect and destroy the session when they close the browser as well as update their login information in the database.

Link to comment
https://forums.phpfreaks.com/topic/238544-php-sessions-and-login/
Share on other sites

what I normally do is have a javascript/ajax with a little timeout (say every 60 seconds so it doesn't use too much resources) that checks if the users are still logged in and saves the time of the last update. whenever it runs, all the users that have not updates for over 65 seconds are considered logged out, the I update the sessions accordingly.

  • 2 weeks later...

thanks all for the input, i know JavaScript can tend to be unreliable some times especially in cases where its turned off. i have kinda solved the problem by running a cron job once every 3 or 4hrs to remove session data as each login session is unique and will be ended once the browser is closed. Hence i look for those special cases once every 4 hrs. Any additional inputs will be appreciated.

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.