How To Specify Domain and Path for a Cookie


How To Specify Domain and Path for a Cookie? - PHP Script Tips - Understanding and Managing Cookies



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, "/", "");
  setcookie("PreferredColor","Blue", NULL, "/", "");
    "/store", "");
    "/store", "");
  print("2 temporary cookies were delivered.\n");
  print("2 consistent cookies were delivered.\n");

2007-04-24, 4855👍, 0💬