Home  >  Article  >  Backend Development  >  php cookie read set delete instance_PHP tutorial

php cookie read set delete instance_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 16:54:401040browse

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);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631738.htmlTechArticlephp cookie read setting and deletion example article uses two examples to tell about setting cookies and reading cookies in php And cookie deletion and other processing methods. If you need to update the cookie to allow it to be stored...
Statement:
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