contra10 Posted March 10, 2009 Share Posted March 10, 2009 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> Quote Link to comment Share on other sites More sharing options...
contra10 Posted March 10, 2009 Author Share Posted March 10, 2009 i've tried setting the cookie in the past with $past still nothing. Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 10, 2009 Share Posted March 10, 2009 maybe it because your posting inside the cookie, try it as a variable. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.