note 71743 added to function.setcookie
| From: | kurtubba at gmail dot com | Date: | Thu, 14 Dec 2006 01:12:51 +0000 |
| Subject: | note 71743 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120593@lists.php.net to get a copy of this message | ||
When setting a top level domain ex ".mydomain.com" you must add the secure arg so it
should look like
setcookie("TestCookie", $value, time()+3600, "/", ".example.com", 0);
ignoring the secure arg makes IE ignores the cookie
to get the top level domain use
$myDomain = ereg_replace('^[^\.]*\.([^\.]*)\.(.*)$',
'\1.\2',$_SERVER['HTTP_HOST']);
to avoid localhost switch use
$phpCkDmn = $_SERVER['HTTP_HOST'] != "localhost" ? $myDomain : false;
----
Server IP: 66.163.161.117
Probable Submitter: 217.54.2.241
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit -- https://master.php.net/note/edit/71743
Del: integrated -- https://master.php.net/note/delete/71743/integrated
Del: useless -- https://master.php.net/note/delete/71743/useless
Del: bad code -- https://master.php.net/note/delete/71743/bad+code
Del: spam -- https://master.php.net/note/delete/71743/spam
Del: non-english -- https://master.php.net/note/delete/71743/non-english
Del: in docs -- https://master.php.net/note/delete/71743/in+docs
Del: other reasons-- https://master.php.net/note/delete/71743
Reject -- https://master.php.net/note/reject/71743
Search -- https://master.php.net/manage/user-notes.php