セッション(CakePHP 2.x):
APP/config/bootstrap.php
セッションCookieをすべてのサブドメインとトップレベルドメインで有効にするには、実際にファイルに自分で設定する必要があります。
ini_set('session.cookie_domain', '.domain.com');
次に、APP/config/core.php
ファイルでセキュリティを低く設定します。
Configure::write('Security.level', 'low');
「それ以外の場合、referer_checkはCakeSessionオブジェクトの行441で現在のHTTP_HOSTに設定されます。」
セッション(CakePHP 3.x)
セッションCookieパスは、デフォルトでアプリのベースパスになります。これを変更するには、session.cookie_pathini値を使用できます。たとえば、セッションをすべてのサブドメインで維持したい場合は、次のことができます。
Configure::write('Session', [
'defaults' => 'php',
'ini' => [
'session.cookie_path' => '/',
'session.cookie_domain' => '.yourdomain.com'
]
]);
クッキー(CakePHP 2.x):
このページでは、「ドメイン」変数を使用できることを説明しています。
Cookieへのアクセスを許可されたドメイン名。たとえば、「。yourdomain.com」を使用して、すべてのサブドメインからのアクセスを許可します。
彼らのサンプルコードによると:
<?php
public $components = array('Cookie');
public function beforeFilter() {
parent::beforeFilter();
$this->Cookie->name = 'baker_id';
$this->Cookie->time = 3600; // or '1 hour'
$this->Cookie->path = '/bakers/preferences/';
$this->Cookie->domain = 'example.com';
$this->Cookie->secure = true; // i.e. only sent if using secure HTTPS
$this->Cookie->key = 'qSI232qs*&sXOw!';
$this->Cookie->httpOnly = true;
}
クッキー(CakePHP 3.x):
ここを読んでください。
Cookieが利用可能なドメイン。example.comのすべてのサブドメインでCookieを使用できるようにするには、ドメインを「.example.com」に設定します。