Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please help me by telling what is site-wide cookies in PHP. This question while reading an article. Please help. I will grateful to you.


share|improve this question

Site-wide cookies are cookies that are valid in the whole site (domain). In order to achieve this, you would need to set the correct parameters in the PHP function setcookie().

For example:

setcookie("TestCookie", $value, time()+3600, "/", "example.co.uk");

This would be a site-wide cookie for the domain example.co.uk, and it would last 1 hr.

share|improve this answer
Specifically, a site-wide cookie is available on all subdomains of that domain. – w3dk Oct 10 '12 at 16:13
Let me emphasize the path attribute here ("/") that makes it site-wide. The attribute is part of all three cookie specifications (Netscape and two RFC's) and if the path attribute is missing, the current path is assumed which is the location of your cookie-setting-script (and then possibly not side-wide but bound to that location). – initall Oct 10 '12 at 18:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.