How to set a cookie in php
| Cookies in PHP can be set using the setcookie() function. This must appear before the HTML tag.
Syntax: Setcookie(name, value, expire, path, domain); Example: here, the cookie name sample is assigned a value jim. The cookie expires after an hour. Setcookie("example", "qsn", time()+3600); Retrieving cookie value: The cookie that is set can be retrieved as shown below: Echo $_cookie |
|
| ["user"”];
Isset() function can be used to find if the cookie is set. | |
