Cookie code works here, but not there?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Cookie code works here, but not there?

Post by JAB Creations »

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,'/');}
}
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Is the cookie being added to the response headers? Is the cookie's domain improper?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

Ah, I knew it was something retarded, but I underestimated just how dense the retardation was! The chat room (php Free Chat) was deleting my cookie! WTF! 8O Well that's why I've been referring to it as experimental...
Post Reply