tags:

views:

139

answers:

3

I want to expire my previous page whet end user clicks on LogOut or Back button of browser. (PHP)

+5  A: 

If you include this at the top of all of your pages, it will require the client to always reload the content, making the back-button requesting a new copy of the page.

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

http://no.php.net/manual/en/function.header.php

sshow
It is not working on my localhost does it work on server??
nectar
It does work on localhosst and remote for me. You should inspect HTTP headers using firebug, or a debugging proxy like fiddler.
Benoit
This should work, unless your computer time is actually before 26th of July, 1997. Make sure you are also destroying the user session.
sshow
A: 

destroy the session key with session_destroy();

rosscompwiz
A: 

You could have some issues with the browser back button, because when clicked, some browsers simply don't reload the page from the server and displays the previous state of the page from the cache.

Zsolti