Home  >  Article  >  php教程  >  cookie用法示例

cookie用法示例

WBOY
WBOYOriginal
2016-06-07 11:45:561871browse

cookie方法是ThinkPHP内置的函数,用于完成cookie的设置、获取和删除操作。
设置cookie('name','value');  //设置cookie<br> cookie('name','value',3600); // 指定cookie保存时间为1小时高级设置cookie('name','value',array('expire'=>3600,'prefix'=>'think_')); // 指定有效期和前缀<br> // 下面的代码和上面等效<br> cookie('name','value','expire=3600&prefix=think_')获取$value = cookie('name');无论是否设置了前缀参数,cookie方法会自动判断。
删除
删除某个cookie值,可以用:cookie('name',null);如果需要清空cookie,可以用:cookie(null); // 清空当前设定前缀的所有cookie值<br> cookie(null,'think_'); //  清空指定前缀的所有cookie值

AD:真正免费,域名+虚机+企业邮箱=0元

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
Previous article:显示彩虹字符串Next article:判断数组序列化