Jump to content

Recommended Posts

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

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;

}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.