Common PHP Header Functions: setcookie()

  1. header()
  2. Common PHP Header Functions
  3. apache_request_headers()

This lets you send cookies to the client without knowing the format for the Set-Cookie header.

setcookie("TestCookie", $value);

setcookie("TestCookie", $value, time()+3600);  /* expire in 1 hour */

setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1);

  1. header()
  2. Common PHP Header Functions
  3. apache_request_headers()