Jump to content

still having cookie problems


contra10

Recommended Posts

I don't know if its the fact that im using a localhost to test this out as to why my cookie sometimes deletes

 

setting the cookie

<?php

// 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("Location: http://localhost/main/"); 
?>

 

deleting the cookie

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

header("Location: http://localhost/"); 
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<?php echo "<a style='text-decoration:none' href='http://localhost/profile/index.php?user=$user'><FONT FACE='ariel' SIZE='2' color='blue'><b>$userq</b></FONT></a>";?>
<input type="submit" name="logout" value= "LOGOUT"/>
</FONT><a style="text-decoration:none" href="http://localhost/main/"><FONT FACE="ariel" SIZE="2" color="blue"><b>Main </FONT></a>
</b>
</form>

Link to comment
https://forums.phpfreaks.com/topic/148710-still-having-cookie-problems/
Share on other sites

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.