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> Link to comment https://forums.phpfreaks.com/topic/148710-still-having-cookie-problems/ 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. Link to comment https://forums.phpfreaks.com/topic/148710-still-having-cookie-problems/#findComment-780859 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. Link to comment https://forums.phpfreaks.com/topic/148710-still-having-cookie-problems/#findComment-780881 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.