drranch Posted July 26, 2006 Share Posted July 26, 2006 :-\I'm using a logout script, but when I select the back browser button I'm still logged in. Here is the code.....session_start();if(!isset($_REQUEST['logmeout'])){ echo "<center>Are you sure you want to logout?</center><br />"; echo "<center><a href=logout.php?logmeout=true>Yes</a> | <a href=javascript:history.back()>No</a>"; } else { session_destroy();}?> Quote Link to comment https://forums.phpfreaks.com/topic/15653-need-help-wsession_destroy/ Share on other sites More sharing options...
drranch Posted July 26, 2006 Author Share Posted July 26, 2006 so I figured out that this only ends the session on the file system and not the session cookie from the browser. How would I remove the session cookie from the browser? ??? Quote Link to comment https://forums.phpfreaks.com/topic/15653-need-help-wsession_destroy/#findComment-63807 Share on other sites More sharing options...
Moon-Man.net Posted July 26, 2006 Share Posted July 26, 2006 Its a bit of a hack, but maby set it to something that isnt going to be valid. EG i use "in" and "out" for my logged in session, and it just gets set to "als;dfjnasf" if they are logged out.and when i validate if they are logged in, obviousally "asdfaSDF" isnt a valid entry, so it rejects them.Might help.Cheers,Nathan Quote Link to comment https://forums.phpfreaks.com/topic/15653-need-help-wsession_destroy/#findComment-63829 Share on other sites More sharing options...
redarrow Posted July 26, 2006 Share Posted July 26, 2006 A session is set untill you close the browser ok.you could try unset($session_name); ok Quote Link to comment https://forums.phpfreaks.com/topic/15653-need-help-wsession_destroy/#findComment-63875 Share on other sites More sharing options...
Rich464 Posted July 26, 2006 Share Posted July 26, 2006 when wanting to end a session it is essential that you unset any session variables you have previously set, eg,session_start();if(!isset($_REQUEST['logmeout'])){ echo "<center>Are you sure you want to logout?</center>"; echo "<center><a href=logout.php?logmeout=true>Yes[/url] | <a href=javascript:history.back()>No[/url]";} else {[color=green]unset($_SESSION['session_var_here']);[/color]session_destroy();}?>so you need to use unset(); on any session vars before you call session_destroy() or you will get the the problem you detailed Quote Link to comment https://forums.phpfreaks.com/topic/15653-need-help-wsession_destroy/#findComment-63885 Share on other sites More sharing options...
redarrow Posted July 26, 2006 Share Posted July 26, 2006 Also read this as a refrence ok.session_destroy() destroys all of the data associated with the current session. It does not unset any of the global variables associated with the session, or unset the session cookie. In order to kill the session altogether, like to log the user out, the session id must also be unset. If a cookie is used to propagate the session id (default behavior), then the session cookie must be deleted. setcookie() may be used for that. Quote Link to comment https://forums.phpfreaks.com/topic/15653-need-help-wsession_destroy/#findComment-63886 Share on other sites More sharing options...
Rich464 Posted July 26, 2006 Share Posted July 26, 2006 assuming that the unique session ID is used as part of the authentication method otherwise there is no need to delete the cookie only to unset any global session variables and to call the session destroy function Quote Link to comment https://forums.phpfreaks.com/topic/15653-need-help-wsession_destroy/#findComment-63890 Share on other sites More sharing options...
redarrow Posted July 26, 2006 Share Posted July 26, 2006 god dam your grate rich! Quote Link to comment https://forums.phpfreaks.com/topic/15653-need-help-wsession_destroy/#findComment-63901 Share on other sites More sharing options...
Rich464 Posted July 26, 2006 Share Posted July 26, 2006 if that was supposed to say 'great' then thanx :)but not as great as these forums ;) Quote Link to comment https://forums.phpfreaks.com/topic/15653-need-help-wsession_destroy/#findComment-63908 Share on other sites More sharing options...
drranch Posted July 26, 2006 Author Share Posted July 26, 2006 ???So I added the unset $_SESSION["session_id"], but I'm still logged in when I select the browsers back button. ::)I'm reading up on this schtuff at .....http://www.captain.at/howto-php-sessions.phpAnd its making sense more and more.... Quote Link to comment https://forums.phpfreaks.com/topic/15653-need-help-wsession_destroy/#findComment-64172 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.