This morning I wanted to make a function. After the user logged in, I saved the user's name in a cookie, but I started to use the method of reading the cookie, but it didn't work. Later I found that using setcookie() must be followed by time. Below I Let me introduce it.
Grammar
setcookie(name,value,expire,path,domain,secure)
Parameter Description
name required. Specifies the name of the cookie.
value required. Specifies the value of the cookie.
expire is optional. Specifies the validity period of the cookie.
path is optional. Specifies the server path for cookies.
domain is optional. Specifies the domain name for the cookie.
secure Optional. Specifies whether cookies are transmitted over a secure HTTPS connection.
For example, a simple assignment to a cookie
The code is as follows
|
Copy code
|
||||||||
$value = "my cookie value";
setcookie("TestCookie",$value, time()+3600*24); ?>
For example, two-dimensional array is stored in cookie
Previous article:The difference between PHP array merge and addition and array_merge_PHP tutorial
Next article:Some uncommon methods of for loop statements in PHP_PHP Tutorial
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Group MySQL results by ID for looping over
I have a table with flight data in mysql. I'm writing a php code that will group and displ...
From 2024-04-06 17:27:56
0
1
406
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|