0

I have a logout script where I'm trying to clear all session data. Whenever I do this i can navigated back to any page and the variables are still being used.

<?php
session_start();
session_destroy();
header('Location: index.php');
?>
3
  • Pressing back will usually show a cached version of the page. Refreshing on that cached page, which makes a new request, should show as logged out. Commented Jul 12, 2018 at 0:30
  • you are right it is cached. Commented Jul 12, 2018 at 0:32
  • Have a look at:: stackoverflow.com/questions/31735428/… It probably will answer your question. Commented Jul 12, 2018 at 0:44

1 Answer 1

1

You should disable the cache on the pages that change on login

header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0 "); // Proxies.

This code is from prevent browser back button cache.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.