Home  >  Article  >  Backend Development  >  怎么设置cookie作用域

怎么设置cookie作用域

PHPz
PHPzOriginal
2016-06-06 20:35:443498browse

设置cookie作用域的方法:首先找到php的“setcookie();”;然后修改代码为“setcookie('name','zhangsan',0,'/', '.baidu.com'”)即可设置指定的作用域。

怎么设置cookie作用域

怎么设置cookie作用域?

提出问题:

php 的 setcookie('name','zhangsan',0,'/');这样的cookie种下之后发现

它的作用域是 www.baidu.com

如何将这个cookie作用域设置为 .baidu.com 呢?

解决方法:

setcookie('name','zhangsan',0,'/', '.baidu.com');

更多相关技术知识,请访问PHP中文网

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