LostKID Posted September 16, 2009 Share Posted September 16, 2009 Hi i was wondering is there anyway to destory a session after say 60 mins of inactivity or after thr browser is closed? Can i use just sessions? or do i have have to use cookies? I have been looking around and was wondering if this would work.. this is on the login_process.php define(COOKIE_DIR, '/'); define(COOKIE_MAXLIFE, '1800'); define(GC_MAXLIFE, '1800'); session_save_path(SESSION_PATH); ini_set('session.gc_maxlifetime', GC_MAXLIFE); session_set_cookie_params(COOKIE_MAXLIFE, COOKIE_PATH); session_start(); $_SESSION['auth'] = "yes"; $_SESSION['email'] = $email; $_SESSION['online'] = 1; Quote Link to comment Share on other sites More sharing options...
Garethp Posted September 16, 2009 Share Posted September 16, 2009 Well, Sessions are automatically destroyed when the browser is closed Quote Link to comment Share on other sites More sharing options...
LostKID Posted September 16, 2009 Author Share Posted September 16, 2009 well mine dont.. look. http://www.brokenbox.co.uk/MY register then close browser without logging out and go back and you will still be signed in. :S.. Quote Link to comment Share on other sites More sharing options...
Mark Baker Posted September 16, 2009 Share Posted September 16, 2009 Well, Sessions are automatically destroyed when the browser is closedNot strictly true. Sessions are destroyed after a period of inactivity. Unless the browser makes a call to the server when it's closed, then there's no way that PHP running on the server can know that it has been closed. Quote Link to comment Share on other sites More sharing options...
LostKID Posted September 16, 2009 Author Share Posted September 16, 2009 so does anyone know how i can tell the sessions to destory themselves if the session wasnt destroyed before they close the browser? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted September 16, 2009 Share Posted September 16, 2009 all you need to do is set the session.gc_maxlifetime to 1800, as for clearing session when the browser is closed, i really don't see the point but you could create a "still here" script that tells the server the client is still active but that seams totally a waste of resource and effort. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.