Home  >  Article  >  Backend Development  >  不设置.domain.com子域之间能共享session吗?

不设置.domain.com子域之间能共享session吗?

WBOY
WBOYOriginal
2016-06-06 20:24:291309browse

不同子域名之间共享session,不设置域名为.domain.com可以做到吗?因为这样设置之后,静态文件的子域名也会被设置,不想让静态文件的子域名被污染,不知道怎样做才行?

回复内容:

不同子域名之间共享session,不设置域名为.domain.com可以做到吗?因为这样设置之后,静态文件的子域名也会被设置,不想让静态文件的子域名被污染,不知道怎样做才行?

Session依赖Cookie进行记录,域名其实就是Cookie的作用域。
你可以使用URL记录Session ID来避开Cookie,不过这绝对不是一个好的方案。
另外,完全看不懂为什么要害怕静态文件的域名被污染,Session为什么会污染静态文件。

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