Jump to content

Archived

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

crouchjay

Log off

Recommended Posts

I have a table for users that are currently online, how do I set them offline if they click the close browser button? Can I retrieve this action? Thanks for your help?

Share this post


Link to post
Share on other sites
possibly with some javascript event checking like an onclose, doing some ajax to update it. but i'm not sure if it is possible for you to get onclose to execute a function if the user straight up clicks the close window X button. it is for sure not possible with only php.

Share this post


Link to post
Share on other sites
How do other sites take care of this problem? Do I need to create a deamon that checks connectivity of users every so often?

Share this post


Link to post
Share on other sites
it's simple, you have an expiry for the session which is set to about lets say 30 minutes after each action of that same user within the site, then in the session verification which each user has on every page load add an sql line which checks `expire` vs. the time() and those which are less than time() are deleted (logged off)

Share this post


Link to post
Share on other sites
yes, you will have to do like a cron job to check the last activity of the person, if you want strictly php. with php you simply don't know if the user is taking a really long time reading a post or something, or if they closed their browser or what.

Share this post


Link to post
Share on other sites

×

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.