Modifying a Cookie
suggest changeChange a cookie by sending it again with setcookie:
setcookie("user", "John", time() + 86400, "/"); // assuming there is a "user" cookie already
Cookies are part of the HTTP header, so setcookie() must be called before any output is sent to the browser.
The path and domain must match the existing cookie, or the browser stores a second cookie.
secure,httponly, andsamesitealso identify the cookie in current browsers.
setcookieURL-encodes the value. PHP decodes it into$_COOKIEunder the cookie's name. It does not create a variable with that name.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents