note 48151 deleted from function.setcookie by tularis

From: Date: Sun, 02 Jan 2005 14:12:50 +0000
Subject: note 48151 deleted from function.setcookie by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-82569@lists.php.net to get a copy of this message
Note Submitter: sijmen at digitized dot nl ---- I've noticed something very strange. It kept me a full day debugging.. I was programming my web application and I'm alwasy using Firefox for viewing web sites, so to look if my web application was working under Internet Explorer (IE), it said IE was refusing the cookies the web application had set, but IE had cookies enabled! Very strange this. What was the problem? <?php // simplified funciton function trb_setCookie ($name, $value, $time=0) { setcookie($name, $value, $time); } trb_setCookie ('name', 'value'); // cookie wil be set in Firefox as a session cookie, but IE sees it as a cookie from 1970 (timestamp: 0). ?> Solution <?php function trb_setCookie ($name, $value, $time=false) { setcookie($name, $value, $time); } ?> Note that the third parameter of setcookie() has to be a bool (false) or a timestamp integer (0 and up) -- Sijmen Ruwhof

« previous php.notes (#82569) next »