The setcookie() function sends an HTTP cookie to a client.
A cookie is a variable, sent by the server to the browser. A cookie is typically a small text file that the server embeds on the user’s computer. Each time the same computer requests a page with a browser, it will send the cookie too.
The name of the cookie is automatically assigned to a variable of the same name. For example, if a cookie was sent with the name “user”, a variable is automatically created called $user, containing the cookie value.
A cookie must be assigned before any other output is sent to the client.
This function returns TRUE on success or FALSE on failure.
W3school