Home > Article > Backend Development > How to set cookies in php
The method for setting cookies in php is: you can use the setcookie() function to set it, and the function must be located before the tag. The specific setting method is: [setcookie('mycookie','value');].
#Cookies are often used to identify users. A cookie is a small file that a server leaves on a user's computer. Each time the same computer requests a page through the browser, the cookie will be sent to the computer.
(Recommended tutorial: php tutorial)
The setcookie() function is used to set cookies. This function must be located before the 100db36a723c770d327fc0aef2ce13b1 tag.
Grammar:
setcookie(name, value, expire, path, domain);
Code implementation:
setcookie('mycookie','value'); echo($mycookie); echo($HTTP_COOKIE_VARS['mycookie']); echo($_COOKIE['mycookie']);
The above is the detailed content of How to set cookies in php. For more information, please follow other related articles on the PHP Chinese website!