我使用的是atk4基本身份验证,因此当我登录此处时http://subdomain1.DOMAIN.pk/index.html
我看到了的所有细节
you are visiting: subdomain1
your site : subdomain2
This is not your site string(23) "abc@gmail.com" You are logged in as :abc@gmail.com
然后我参观这个http://subdomain2.DOMAIN.pk/login.html
它将我重定向到登录
但我已经登录了http://subdomain1.DOMAIN.pk/index.html
子域会影响cookie吗?
这是我的代码:
$this->add('BasicAuth');
$this->auth->setModel('User');
//if site is a user site
if ($this->api->skin != 'default' && !$this->auth->isLoggedIn()) { // && $this->privacy == $this->PRIVATE) {
if(!$this->auth->isPageAllowed($this->page)){
$this->auth->check();
}
echo 'you are visiting: '. $this->api->siteName;
//echo $this->api->siteName;
$m = $this->add('Model_Site');
$tm = $m->loadBy('user_id', $this->auth->get('id'));
$this->mySite = $tm->get('name');
//->ref($this->auth->get('id'));
echo '<br/>';
echo 'your site : '. $this->mySite;
echo '<br/>';
if ($this->siteName == $this->mySite) {
echo 'This is your site';
} else {
echo 'This is not your site';
}
//var_dump($this->auth->get('siteName'));
// var_dump($this->auth->model->ref('theme_id')->get('name'));
//if ($this->auth->get('sitename', skinName))
}
//maindomain
if ($this->api->skin == 'default') {
$this->add('BasicAuth');
$this->auth->allowPage('index');
$this->auth->allowPage('signup');
$this->auth->setModel('User');
if(!$this->auth->isPageAllowed($this->page)){
$this->auth->check();
}
}
我看到了一些与这个话题相关的stackoverflow帖子。我想知道如何在atk4中解决它。
以下是链接:
- 子域example.com可以设置一个example.com可以读取的cookie吗
- Cookie和子域
在agiletoolkit中解决此问题的最佳方法是在config:中添加这一行
$config['session']['domain'] = '.DOMAIN.pk';
查看cookie的"path"参数http://www.php.net/manual/en/function.setcookie.php
可能您需要指定它。