kadamsurekha Posted June 11, 2007 Share Posted June 11, 2007 hello all! I have designed a website wherein user login. i want the user to logout when clicked on "logout" link. i have written a code as follows: 1 page which has logout link <a href="index.php">LOGOUT</a> on index page (index.php), i have written the code as <? session_start(); session_destroy(); ?> on click of the LOGOUT link the index.php page opens. but if i click on the back button of the explorer the previous page opens n shows the data. i want the page to expire once logout. wht can be done to achieve this?? can any1 help??????????? Link to comment https://forums.phpfreaks.com/topic/55113-session_destroy-in-php/ Share on other sites More sharing options...
smc Posted June 11, 2007 Share Posted June 11, 2007 Well that will work, but on the page that requires a logged in session be sure to have something like this. Create a session variable to track the status of a session, theres a few other ways to do this but I always found it easiest. Have this when the user is sucessfully logged in: $_SESSION['enabled'] = "yup"; Then on your pages requiring logged in session session_start(); if( !isset( $_SESSION['enabled'] ) ){ echo( "Your not logged in, pal!" ); die; } Link to comment https://forums.phpfreaks.com/topic/55113-session_destroy-in-php/#findComment-272458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.