Home > php教程 > php手册 > body text

php cookie注销 设置 输出和注销学习笔记

WBOY
Release: 2016-06-13 10:16:49
Original
692 people have browsed it

这是一个朋友在学php时的一个学习笔记,其功能就是设置cookie然后注销及输出cookie值的具体操作方法。

setcookie() 函数用于设置 cookie。

注释:setcookie() 函数必须位于 标签之前。

语法

setcookie(name, value, expire, path, domain);

下面看实例

 代码如下 复制代码


//注销cookie
if(isset($_GET['out'])){
setcookie('us',"");
echo "<script>location.href='index.php'</script>";
}

//设置cookie
if(isset($_POST['sub'])){
setcookie("us",$_POST['user'],time()+3600);
echo "<script>location.href='index.php'</script>";
}

//输出和注销cookie
if($_COOKIE['us']){
echo $_COOKIE['us'];
echo "注销cookies";
}

?>





source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!