Jump to content

[SOLVED] can't kill cookie


contra10

Recommended Posts

i can't kill my cookie

 

set cookie in login

// if login is ok then we add a cookie 
$_POST['username'] = stripslashes($_POST['username']); 
$hour = time() + 3600; 
setcookie(ID_my_site, $_POST['username'], $hour); 
setcookie(Key_my_site, $_POST['pass'], $hour);

 

header

<?php
//checks cookies to make sure they are logged in 
if(isset($_COOKIE['ID_my_site'])) 
{ 
$username = $_COOKIE['ID_my_site']; 
$pass = $_COOKIE['Key_my_site']; 
}
...
reference to logout.php
echo "<a style='text-decoration:none' href='http://localhost/logout/logout.php'><FONT FACE='ariel' SIZE='2' color='#5f5f5f'>Logout</FONT></a>";
?>

 

logout.php

<?php 
if(isset($_COOKIE['ID_my_site'])) 
{ 
$username = $_COOKIE['ID_my_site']; 
$pass = $_COOKIE['Key_my_site']; 
}
$past = time() - 3900; 
//this makes the time in the past to destroy the cookie 
setcookie(ID_my_site, $username, $past); 
setcookie(Key_my_site, $pass, $past); 

header("Location: http://localhost/"); 
?> 	

Link to comment
https://forums.phpfreaks.com/topic/148118-solved-cant-kill-cookie/
Share on other sites

setcookie('ID_my_site', false); 
setcookie('Key_my_site', false);

 

Give that a try.

 

Because setting a cookie with a value of FALSE will try to delete the cookie, you should not use boolean values. Instead, use 0 for FALSE  and 1 for TRUE.

 

setcookie

 

EDIT:

If that fails, follow PFMaBismAd instructions. Also you should set the past to be at least 1 year ago, due to timezone differences.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.