I’d like to induce a function after the session is destroyed (i.e. user closes the browser). This function would change a value in my database from true to false. Is that possible?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would suggest you to register the user last activity in your database, this way it’s 100% accurate.
Then by comparing the registered date with the current time, you can decide when the user is active or not.
If you really want to know if the user is still on your page, you could also do something, but you should avoid it :
On the client side, make a javascript loop, for example each minute, that tell to your server the client is still there. When the client will close his page, the loop won’t make any new query.