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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.