Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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.

Thanks

share|improve this question
add comment

1 Answer

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
1  
Specifically, a site-wide cookie is available on all subdomains of that domain. –  w3d Oct 10 '12 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 Oct 10 '12 at 18:41
add comment

Your Answer

 
discard

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.