PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Oct 20, 2019 6:06 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Sep 10, 2014 12:40 am 
Offline
Forum Contributor

Joined: Mon Aug 11, 2014 11:18 am
Posts: 179
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.


Top
 Profile  
 
PostPosted: Wed Sep 10, 2014 6:55 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
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.

_________________


Top
 Profile  
 
PostPosted: Thu Sep 11, 2014 8:16 am 
Offline
Forum Newbie

Joined: Mon Sep 08, 2014 11:57 am
Posts: 4
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.


Top
 Profile  
 
PostPosted: Thu Sep 11, 2014 5:24 pm 
Offline
Forum Contributor

Joined: Mon Aug 11, 2014 11:18 am
Posts: 179
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?


Top
 Profile  
 
PostPosted: Thu Sep 11, 2014 6:33 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
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.

_________________


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group