CodeIgniter会话cookie域 [英] CodeIgniter session cookie domain
问题描述
在下面的Cookie设置中,系统会为整个网域设置Cookie。例如,如果我在 http://subdomain.domain.com 上,则会为subdomain.domain.com设置Cookie(如果我位于) domain.com将为domain.com设置cookie。
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.
如果为subdomain.domain.com设置了cookie,则意味着subdomain2.domain.com无法访问来自subdomain.domain.com的Cookie?
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'] = "/";
推荐答案
特定于域的Cookie只能在该域上访问。使用.domain.com作为您的Cookie网域,即可在所有子网域和主网域中使用。
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.
这篇关于CodeIgniter会话cookie域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!