Hello,
is it possible to kill a session when the user exits a certain page?
i only have a few pages on my site that use sessions. i want the session to be destroyed when they leave one of the pages. weather it be they x out, go to a page that doesn't have sessions, or go to a different website.
thank you.
Kill Session On Page Exit
Moderator: General Moderators
Re: Kill Session On Page Exit
If they go to a page where you don't want to use sessions, you can destroy the session right there. For pages you don't control, your best bet would be to set a timeout value on the session.
Re: Kill Session On Page Exit
You also could try to navigate user to the new page ( = leave current page) from this current page (use header()). -> so at the point you redirect user you can also do anything else (for example kill session).
This is may not be a good idea, but what if... just an option.
This is may not be a good idea, but what if... just an option.
Re: Kill Session On Page Exit
basically i am making a order status page and they login by typing their email and order number.. it allows them in if there is a row that exists with that info.. it stores that info in a session. so the order status page will let them in without having to re-login again.. but i want this session to expire after sometime i don't want it to last until it kills itself overtime however it does that. how can i make one that is based on time?
Re: Kill Session On Page Exit
I think a timeout or expiry is the best option here since you can't reliably catch events like them closing the browser or navigating to another site. When you create the session, set an expiry value X time in the future. On any subsequent request, check the current time against that stored value. If the expiry time has passed, kill the session and make them login again.