Jump to content

Archived

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

Hyaku_

how to destroy session after user leaves the website?

Recommended Posts

Hi!
I'm using sessions on my website. I want users to be logged out automaticly after they leave my website, instead of manualy logging out all the time! And I need the session to be destroyed imidietly not after some time! Is this posible? Any suggestions? Thank you!

Share this post


Link to post
Share on other sites
You cant really tell if someone has left your site.  They could of closed it, quit it, their machine could crash.  Only way I guess would be to somehow set up a cron job to go through the directory were the sessions are kept and if they havent been used within a set time, delete it?



Share this post


Link to post
Share on other sites
You cannot destroy the session immediatly as soon the user leaves your site. The only the way you do this is to lower the lifetime of the session, to something like 5mins however if the user leaves his computer for 5mins or more thier session will be destroyed, thefore when they return they'll most probably get a session timeout error message of some sort.

Also sessions become invalid when the user closes their browser and goes to return to your site.

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.