Home > Article > Backend Development > php cookie read set delete instance_PHP tutorial
php cookie read set delete instance The article uses two examples to describe the processing methods of setting cookies, reading cookies and deleting cookies in PHP. If you need to update the cookie to store a new value, just overwrite its original value. Therefore, even if you have just sent a cookie on a previous page, you can still change your name to "jeff".
php tutorial cookie read set delete instance
The article uses two examples to describe the processing methods of setting cookies, reading cookies and deleting cookies in PHP
If you need to update the cookie to store a new value, just overwrite its original value. Therefore, even if you have just sent a cookie on a previous page, you can still change your name to "jeff".
*/
$y2k = mktime(0,0,0,1,1,2000);
setcookie('name', 'jeff', $y2k);
/*
The above is a simple cookie example. Let's look at a complex cookie to use as user login verification example code.
*/
function verify()
{
global $pass;
if($_post['pass'] == $pass || $_cookie['pass'] == md5($pass))
{
Cookie(true);
Return true;
}
else
{
Cookie(false);
Return false;
}
}function cookie($set = true)
{
global $pass;
if($set)
setcookie("pass",md5($pass),time()+3600);
else
setcookie("pass","",time()-3600);
}