ypran Posted April 24, 2008 Share Posted April 24, 2008 After destroying the session by clicking on logout present in mainpage. If the user tries clicking on 'back' navigator button on the browser page it is even then showing the mainpage. How to solve this problem? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/102680-how-to-destroy-sessions-in-php/ Share on other sites More sharing options...
JasonLewis Posted April 24, 2008 Share Posted April 24, 2008 It's probably just stored in the cache, just re-direct the user after the logout to a confirmation page saying they logged out and it should be fine. Link to comment https://forums.phpfreaks.com/topic/102680-how-to-destroy-sessions-in-php/#findComment-526002 Share on other sites More sharing options...
SharkBait Posted April 24, 2008 Share Posted April 24, 2008 $_SESSION = array(); session_destroy(); I think that is what I do to ensure the session has been killed Link to comment https://forums.phpfreaks.com/topic/102680-how-to-destroy-sessions-in-php/#findComment-526009 Share on other sites More sharing options...
soycharliente Posted April 24, 2008 Share Posted April 24, 2008 Are you using session_destroy()? On the top of each of my pages that are protected by a login, I usually include a file that has some code like the following: <?php if (isset($_SESSION['something'])) { // show page } else { header("Location: index.php"); exit; } ?> It works very well for what I use it for. Link to comment https://forums.phpfreaks.com/topic/102680-how-to-destroy-sessions-in-php/#findComment-526011 Share on other sites More sharing options...
JasonLewis Posted April 24, 2008 Share Posted April 24, 2008 Are you using session_destroy()? On the top of each of my pages that are protected by a login, I usually include a file that has some code like the following: <?php if (isset($_SESSION['something'])) { // show page } else { header("Location: index.php"); exit; } ?> It works very well for what I use it for. You could just use: if(!isset($_SESSION['something'])){ header("Location: index.php"); exit; } And it wouldn't show the page. Link to comment https://forums.phpfreaks.com/topic/102680-how-to-destroy-sessions-in-php/#findComment-526016 Share on other sites More sharing options...
The Little Guy Posted April 24, 2008 Share Posted April 24, 2008 Delete the cookie too From php.net: <?php // Initialize the session. // If you are using session_name("something"), don't forget it now! session_start(); // Unset all of the session variables. $_SESSION = array(); // If it's desired to kill the session, also delete the session cookie. // Note: This will destroy the session, and not just the session data! if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time()-42000, '/'); } // Finally, destroy the session. session_destroy(); ?> Link to comment https://forums.phpfreaks.com/topic/102680-how-to-destroy-sessions-in-php/#findComment-526018 Share on other sites More sharing options...
jonsjava Posted April 24, 2008 Share Posted April 24, 2008 the paranoid version: <?php session_start(); session_unset(); session_destroy(); $_SESSION = array(); header("location:index.php"); exit(); ?> Link to comment https://forums.phpfreaks.com/topic/102680-how-to-destroy-sessions-in-php/#findComment-526019 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.