Specifying Domain and Path for a Cookie in PHP


How To Specify Domain and Path for a Cookie in PHP?

✍: FYIcenter.com


If you want to specify domain and path for cookie, you can use the setcookie() function with two extra parameters. The sample PHP script below shows you how to set the domain and path attributes for temporary and persistent cookies:

  setcookie("LoginName","FYICenter", NULL, "/", ".fyicenter.com");
  setcookie("PreferredColor","Blue", NULL, "/", ".fyicenter.com");
    "/store", ".fyicenter.com");
    "/store", ".fyicenter.com");
  print("2 temporary cookies were delivered.\n");
  print("2 consistent cookies were delivered.\n");


Mistake on Setting Cookie Path and Domain in PHP

Domain and Path Attributes for Cookies in PHP

Understanding and Managing Cookies in PHP

⇑⇑ PHP Tutorials

2016-11-03, 1923🔥, 0💬