Log Out Script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Brad7928
Forum Commoner
Posts: 39
Joined: Thu Jan 29, 2009 4:54 pm

Log Out Script

Post by Brad7928 »

I have a log in script that set's a cookie, each page they visit looks for this cookie, if they don't have it, they are directed to the log in screen. When user's log out it runs the script below to delete the cookie, which works fine.

Code: Select all

<?php 
$past = time() - 200; 
//this makes the time in the past to destroy the cookie 
setcookie(ID_my_site, gone, $past); 
setcookie(Key_my_site, gone, $past); 
header("Location: /gaming/index2.php"); 
?>
Problem is that the pages they have visited can still be seen if they haven't closed there browser because it stores them in temp internet files. Is there a way to delete it from temp internet files, or make it get an updated version of the page each time they try to access it?

I think i've seen it done before in the header, it sets a time on how long the page is valid for or something?
User avatar
nor0101
Forum Commoner
Posts: 53
Joined: Thu Jan 15, 2009 12:06 pm
Location: Wisconsin

Re: Log Out Script

Post by nor0101 »

Yeah, put these before you do any output to the page.

Code: Select all

 
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Mon, 23 Jun 1986 12:00:00 GMT"); // This date is in the past.
    header("Pragma: no-cache");
 
Brad7928
Forum Commoner
Posts: 39
Joined: Thu Jan 29, 2009 4:54 pm

Re: Log Out Script

Post by Brad7928 »

nor0101 wrote:Yeah, put these before you do any output to the page.

Code: Select all

 
    header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    header("Expires: Mon, 23 Jun 1986 12:00:00 GMT"); // This date is in the past.
    header("Pragma: no-cache");
 
Worked a treat, your a genius lol.

Cheers buddy!
Post Reply