Home  >  Article  >  Backend Development  >  如果setcookie为其它域名下?

如果setcookie为其它域名下?

WBOY
WBOYOriginal
2016-06-06 20:28:261222browse

比如我想设置为baidu.com的cookie,为啥domain不管用呢

回复内容:

比如我想设置为baidu.com的cookie,为啥domain不管用呢

同源策略限制

出于安全考虑,浏览器会阻止跨域设置cookie.举个例子:比如一个恶意网站的页面通过iframe嵌入了银行的登录页面(二者不同源),如果没有同源限制,恶意网页上的javascript脚本就可以在用户登录银行的时候获取用户名和密码。所谓同源:URL由协议、域名、端口和路径组成,如果两个URL的协议、域名和端口相同,则表示他们同源.在浏览器中,如果setcookie为其它域名下?等标签都可以加载跨域资源,而不受同源限制,而cookie则受到同源的限制。

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