CodeIgniter session cookie domain

匿名 (未验证) 提交于 2019-12-03 01:29:01

问题:

It appears with the following cookie settings below, that cookies are set for the entire domain. For example if I was on http://subdomain.domain.com the cookie would be set for subdomain.domain.com if I was on domain.com the cookie would be set for domain.com.

If the cookie is set for subdomain.domain.com that does that mean subdomain2.domain.com cannot access a cookie from subdomain.domain.com?

/* |-------------------------------------------------------------------------- | Cookie Related Variables |-------------------------------------------------------------------------- | | 'cookie_prefix' = Set a prefix if you need to avoid collisions | 'cookie_domain' = Set to .your-domain.com for site-wide cookies | 'cookie_path'   =  Typically will be a forward slash | */ $config['cookie_prefix']    = ""; $config['cookie_domain']    = ""; $config['cookie_path']      = "/"; 

回答1:

Domain specific cookies are only accesible on that domain. Use ".domain.com" as your cookie domain to be able to use it across all subdomains and main domain.



回答2:

When using several codeigniter applications on subdomains it is also important to set the same $config[‘encryption_key’].



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