Cookie code works here, but not there?
Posted: Fri May 25, 2007 5:10 am
This snippet is supposed to create a cookie that lives for a month. It has worked just fine for countless months thus far. Now when I use it suddenly the cookies die in seconds of their creation. The only difference I am aware of is the fact that they are created after the page request method is post instead of get. I've changed the form method to get (from post) but receive the same results. There is nothing referring to setting a cookie other then the snippet below so it has to be some sort of rule in regards to cookies that I'm missing?
Code: Select all
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
if(isset($_POST['chatroom']) && $_POST['chatroom']=='1')
{setcookie('chatroom','1',time()+2592000,'/');}
else if ($_SERVER['REQUEST_METHOD'] == 'POST' && !isset($_POST['chatroom'])) {
setcookie('chatroom','0',time()+2592000,'/');}
}
?>