PHP_USER1
PHP_USER1

Reputation: 628

logout is not woking properly

<?php
setcookie("id","",time()-1200,'/bss/bss/');
session_start();
session_destroy();
header("location:http://localhost/bss/bss/");
?>

This is my logout page when i click on this it will redirect me to the header location but when i click on back button on the top-left side , it will show me the whole info but i m logout . and if i refresh on this page again it will show me the normal page without my info cookies is destroyed but when i click on back button why its showing me the page wid my info . is there any way when the user click on the back button IT cant go back

Upvotes: 0

Views: 82

Answers (6)

niteshSrivastava
niteshSrivastava

Reputation: 166

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE, NO-STORE, must-revalidate"> <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> <META HTTP-EQUIV="EXPIRES" CONTENT=0>

its a solution that prevents caching we can't wipe the cache for what they already loaded. You should look it too prevent back button after logout page

Upvotes: 5

Zword
Zword

Reputation: 6793

You need to check if cookie is present in every page with only member access.Do the following if you havent:

1->check if cookie exists

2->if exists show info page

3->doesnt exist redirect to http://localhost/bss/bss/

Upvotes: 0

praveen
praveen

Reputation: 286

Just redirect if there's no login $_SESSION, for example:

//on your protected pages
session_start();
if(!$_SESSION['logged']) {
    header("location:login.php");
}

Upvotes: 1

pratim_b
pratim_b

Reputation: 1200

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE, NO-STORE, must-revalidate">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT=0>

(If you are not using templates) Put this in your html pages

Upvotes: 0

AboQutiesh
AboQutiesh

Reputation: 1716

try this mate

<?php
   setcookie("id","",time()-1200,'/');

   session_start();
   session_destroy();

   header("location:http://localhost/bss/bss/");
?>

Upvotes: 0

Harish Singh
Harish Singh

Reputation: 3329

you need to clear browser cache by using these lines in all pages

header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");

Upvotes: 0

Related Questions