0

I have a logout.php which runs the following code. But it does not clear the session values completely. It redirects me to the homepage as it should. But when I click on back button then the previous page is displayed perfectly. I want to remove the cache values. How to do it?? Please help

<?php
session_start(); 
session_destroy();
header("location:home.php?msg=logout");
?>
Sachin Menon
  • 69
  • 11
  • 1
    Have a look at this: http://stackoverflow.com/questions/13640109/how-to-prevent-browser-cache-for-php-site – Indrajit Apr 08 '16 at 06:54
  • 1
    Or try this one http://stackoverflow.com/questions/3948230/best-way-to-completely-destroy-a-session-even-if-the-browser-is-not-closed – Tom Senner Apr 08 '16 at 07:01

1 Answers1

1
First Check is your previous page has session_start(); because if your previous page has not this session_start(); on top your script it will loads.

now after destroying check actually session are destroyed or not.(obvious it must be destroyed.)

you can also use unset($_SESSION['var_name']); to destroy one session variable.

<?php
session_start(); 
session_destroy();
echo "<pre>";
print_r($_SESSION);
exit;
header("location:home.php?msg=logout");
?>
Rahul
  • 21
  • 2