Home  >  Article  >  Backend Development  >  php cookie的操作实现代码(登录)_PHP

php cookie的操作实现代码(登录)_PHP

WBOY
WBOYOriginal
2016-06-01 12:17:57835browse

Cookie

第一个文件login_frm.php这个是登录窗口
代码
复制代码 代码如下:






用户:





第二个文件login.php这个是处理登录
复制代码 代码如下:
if($_POST['username'] = 'admin')
{
setcookie('haha','gogo');
header("location:index.php");
}
?>

第三个文件index.php再看下效果
复制代码 代码如下:
if($_COOKIE['haha'] == 'gogogo')
{
echo $_COOKIE['haha'];
echo'你设置了cookie';
}
else
{
echo'你没有设置cookie';
}
?>

更基础的可以参考 PHP Cookies
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