note 34531 deleted from function.setcookie by victor

From: Date: Sat, 27 Mar 2004 20:20:05 +0000
Subject: note 34531 deleted from function.setcookie by victor
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-67248@lists.php.net to get a copy of this message
Note Submitter: choprasp@NOSPAM.h_o_ttest_mail.com ---- I just bought a shared webhosting account and I was testing my server. For some strange reason, setcookie() was returning TRUE but was not creating a cookie in my browser. I spent a good hour trying to figure out the problem. my script was cookiemaker.php -------------- <?php setcookie("SID", "abc", time()+10000, "/", ".foobar.com", 0); ?> -------------- The above would not properly set a cookie in my browser. When i changed the expiry from time()+10000 to time()+100000 it worked!! My only explanation for this is that I live on the east coast (Toronto) and the server is located in California. Setting an expiry of time()+10000 actually sets the expiry to a date in the past (relative to Toronto), while time()+100000 sets an expiry date in the future (relative to Toronto). This would explain why I had no problem with setcookie() with my local server in Toronto. So if your setcookie is returning true but not setting a cookie, check the expiry time (and, of course, the path and domain parameters). Hope this helps, Sandy.

« previous php.notes (#67248) next »