Jump to content


Photo

how to destroy session after user leaves the website?


  • Please log in to reply
2 replies to this topic

#1 Hyaku_

Hyaku_
  • Members
  • PipPipPip
  • Advanced Member
  • 44 posts

Posted 06 July 2006 - 06:12 PM

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!

#2 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 06 July 2006 - 06:18 PM

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?





#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 06 July 2006 - 06:20 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users