Jump to content

session_destroy in php


kadamsurekha

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;

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.