emma57573 Posted July 25, 2008 Share Posted July 25, 2008 How do I perform a function on widow close I want to log a user out of a session once they have exited my site. Currently they are staying logged in until the they manually log out so if they just close the browser they are still showing as logged in and it messing my 'user online' script up. I have the function I want to use ready Im just now sure how to tell it to work if the window closes. Im asuming you can do this in PHP Quote Link to comment https://forums.phpfreaks.com/topic/116550-function-on-window-close/ Share on other sites More sharing options...
waynew Posted July 25, 2008 Share Posted July 25, 2008 Maybe Javascript is the best option there. Also, add a session time limit. And reset the time everytime they move a page. So, if they stay inactive...... Quote Link to comment https://forums.phpfreaks.com/topic/116550-function-on-window-close/#findComment-599299 Share on other sites More sharing options...
DeanWhitehouse Posted July 25, 2008 Share Posted July 25, 2008 or simple way would be to use sessions , as they will be destroyed when the browser is closed. Or they timeout after 30 minutes i think Quote Link to comment https://forums.phpfreaks.com/topic/116550-function-on-window-close/#findComment-599401 Share on other sites More sharing options...
emma57573 Posted July 26, 2008 Author Share Posted July 26, 2008 Thank you I looked into the java unLoad option and decided it was to unreliable so I have now killed the session after being inactive for 5 minutes and its working well. The only thing if someones online a button apears 'chat with user' so someone could open a chat session within the 5 minutes the user has been inactive for and it obviously wont work which could be annoying for the user trying to chat. If anyone knows of a reliable way to tell when a browser is closed I would love to hear it otherwise I think this will do for now. Thank you for the advise. Quote Link to comment https://forums.phpfreaks.com/topic/116550-function-on-window-close/#findComment-600058 Share on other sites More sharing options...
JasonLewis Posted July 26, 2008 Share Posted July 26, 2008 Make it less then 5 minutes. Maybe 1 minute. Otherwise no, I don't know of any other way. Quote Link to comment https://forums.phpfreaks.com/topic/116550-function-on-window-close/#findComment-600062 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.