tomjones Posted August 4, 2006 Share Posted August 4, 2006 Hi.I am creating a login component which stores a simple Y/N value in a MySQL database depending on if the login was successful or not. I need to somehow reset this to N when the user closes the browser window. What would be the best way to achieve this with PHP? I can create the sql statement, but how would I go about running a function when the window is closed?Thank you for your time. Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 4, 2006 Share Posted August 4, 2006 I dont think this is possible, Powecuts, Illegal Shut downs ectThe best way to find out who is online isadd a field into the DB, last_action or something, as DATETIME fieldOn the top of every page, have a scriptIf the user is logged in, Update the table with last action of that date timeAnyone who has action within the last 10 minutes you can assume they are online Quote Link to comment Share on other sites More sharing options...
tomjones Posted August 4, 2006 Author Share Posted August 4, 2006 Thanks for your reply. Would that amount of database calls be a bit resource intensive? Quote Link to comment Share on other sites More sharing options...
Vikas Jayna Posted August 4, 2006 Share Posted August 4, 2006 the onbeforeunload javascript event can be used to open a popup window that will call the php script to do the job. However, this does work across all the browsers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.