Note that specifying dot in the domain name is not relevant from server perspective. In PHP, setcookie() method is used to set a cookie. To ensure that a session cookie will be available to both a domain and its subdomains, use the php function session_set_cookie_params and set the domain parameter appropriately: Cookie domain, for example 'www.php.net'. RFC 2965 seems to explicitly state that such a cookie will not be sent to example.com, but then equally says that if you set Domain=example.com, a dot is prepended, as if you said .example.com. Here is how the php code looks like: Here is how the http header received by Firefox browser looks like: Usually cookies which stores login information should be attached to top level domain (tld) and are good candidates for generic domain and subdomain cookies. There is a limit to how many cookies can set per domain. header("Set-Cookie: PHPSESSID=abc; path=/; domain=.sub.domain.com"); header("Set-Cookie: PHPSESSID=abc; path=/; domain=.domain.com"); print_r(headers_list()); // here you see two Set-Cookie headers with domains for PHPSESSID session_id('abc'); session_start(); How to Set Cookies for Multiple subdomains. Cookies are simple text files which store some information on a user computer. So cookie set by webrewrite.com cannot be accessed by example.com. You can try copy paste code above in the Console, and see the result in Resource Panel. If set to "/php/", the cookie will only be available within the php directory and all sub-directories of php. If you want to restrict the cookie to a single host, supply the domain parameter as an empty string. sub1.domain.com and sub2.domain.com. Your domain must be in format of “.domain.com” – dot and root domain and your path=/ always. On the main domain (example.com) where you’re going to ask the other two domains to set the cookie, create an HTML page with the following content : Three parts to what you'll need: 1) http://us2.php.net/manual/en/function.setcookie.php to set the cookie. … To share cookies across subdomains, … you can simply create cookies with the domain directive set … to the parent domain, in this case, example.com, … rather than either of the specific subdomains. The default value is the current directory that the cookie is being set in domain //Syntax to set a cookie. I've tried some of the conventional techniques quoted below (placed at the top of the page right after Ragdoll Kittens For Sale In South Carolina, How Do Chipmunks Find Food, Do Frogs And Turtles Hibernate, White Nosed Coati Niche, Nopalea At Walmart, European Colonization Apush, Black Bullhead Catfish Diet, Thar Wanderlust Second Hand, Nauticstar 243dc Sport Deck, Pet Peacock Bass, Citric Acid For Pool Stains, Covenant College Basketball Schedule,