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.


1 Answer 1


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.

  • 1
    Specifically, a site-wide cookie is available on all subdomains of that domain.
    – MrWhite
    Commented Oct 10, 2012 at 16:13
  • 2
    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
    Commented Oct 10, 2012 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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