setcookie
Setcookie is a PHP function used to send a cookie from the server to the client. It uses the HTTP Set-Cookie header to store data on the user’s device, and the cookie value is returned by the browser with subsequent requests in the Cookie header. The function returns true on success and false on failure.
Signature and options: The traditional signature is setcookie(string $name, string $value = "", int $expires = 0, string $path
Usage: Example: setcookie("user", "alice", time() + 3600, "/"); This creates a cookie named user that expires in one
Lifetime and scope: The expires parameter sets the cookie’s lifetime; 0 means a session cookie. Path and
Notes: Cookies are stored on the client and sent with each request; PHP can read them via
Alternatives: setrawcookie sends the same header without URL-encoding the value.