note 93641 modified in function.setcookie by danbrown

From: Date: Mon, 21 Sep 2009 14:11:24 +0000
Subject: note 93641 modified in function.setcookie by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160894@lists.php.net to get a copy of this message
As <info at daniel-marschall dot de> points out, firefox will prepend a period (full-stop) to the domain value if the period is not already present. This is because firefox expects the domain parameter value, if present, to be a domain name and not a host name. So using setcookie() with a domain value of www.example.com is not correct if www is a host name. If you want to restrict the cookie to a single host, supply the domain parameter as an empty string, for example (note the rightmost parameter): <?php setcookie("TestCookie", "SomeValue", time()+3600, "/~rasmus/", ""); ?> --was-- As <info at daniel-marschall dot de> points out, firefox will prepend a period (full-stop) to the domain value if the period is not already present. This is because firefox expects the domain parameter value, if present, to be a domain name and not a host name. So using setcookie() with a domain value of www.example.com is not correct if www is a host name. If you want to restrict the cookie to a single host, supply the domain parameter as an empty string, for example (note the rightmost parameter): <? setcookie("TestCookie", "SomeValue", time()+3600, "/~rasmus/", ""); ?> http://php.net/manual/en/function.setcookie.php

« previous php.notes (#160894) next »