Codeigniter duplicate session issue

放肆的年华 提交于 2019-12-04 03:46:47

In my applications I place the following code into .htaccess for preventing a cookie to be sent with css/js/images requests:

#.htaccess

# Use Mod_deflate to compress static files
<ifmodule mod_deflate.c>
<filesmatch ".(js|css|ico|txt|htm|html|php)$">
SetOutputFilter DEFLATE
</filesmatch>
</ifmodule>

# Speed up caching
FileETag MTime Size

# Expires
ExpiresActive On
ExpiresDefault "access plus 366 days"

# Future Expires Headers
<filesmatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Sat, 27 Dec 2014 23:59:59 GMT"
</filesmatch>

I had this issue before and the problem was that the CI cookie name cannot have dots in it.

bad cookie name: .domain.com

smooth criminal: mydomaincom

I was using the domain name with dots for the cookie name to enable domain wide cookies (share cookies from the main domain to all its subdomains), turns out I've found that the only thing I needed for that was:

$config['cookie_domain']    = ".domain.com";
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!