0

I'm working on some project on CodeIgniter and I would like to limit cookies on maindomain.tld and www.maindomain.tld, because I have another, third, domain another.maindomain.tld which has installed same application but with a little different features. My config for maindomain.tld is like that:

$config['cookie_prefix']    = "";
$config['cookie_domain']    = "maindomain.tld";
$config['cookie_path']      = "/";
$config['cookie_secure']    = FALSE;

And for another.maindomain.tld:

$config['cookie_prefix']    = "";
$config['cookie_domain']    = "another.maindomain.tld";
$config['cookie_path']      = "/";
$config['cookie_secure']    = FALSE;

Cookies from maindomain.tld are working on another.maindomain.tld which shouldn't be, because databases are different and there might not be same user with same id.

4

1 回答 1

3

我建议你简单地使用前缀。

http://codeigniter.fr/user_guide/helpers/cookie_helper.html

仅当您需要避免与服务器的其他同名 cookie 发生名称冲突时,才需要该前缀。

所以试试这个:

$config['cookie_prefix']    = "main";
$config['cookie_domain']    = "maindomain.tld";
$config['cookie_path']      = "/";
$config['cookie_secure']    = FALSE;


$config['cookie_prefix']    = "sub";
$config['cookie_domain']    = "another.maindomain.tld";
$config['cookie_path']      = "/";
$config['cookie_secure']    = FALSE;
于 2013-08-10T09:48:37.550 回答