-1
我想在子域上使用會話數據。ZEND2:跨域會話
EX:
www.mywebsite.com
test.mywebsite.com
當我嘗試使用會話數據從www.mywebsite.com子域,所有的會話信息不可訪問。
設置會話在同一個域中
public function homeAction($value='')
{
$domain = eregi_replace('^WWW', '', "$_SERVER[HTTP_HOST]");
$subdomain = substr($domain,0);
$request = $this->getRequest()->getHeaders()->get('Set-Cookie')->foo = 'bar';
$response = $this->getResponse()->getCookie()->baz = 'test';
$userSession = new Container('userinfo');
$userSession->email = '[email protected]'; // write session
$userSession->password = 'e10adc3949ba59abbe56e057f20f883eaa';
$dmn_link = 'http://app' . $subdomain . '/auth';
$www_link = 'http://www' . $domain . '/career';
echo "<br/><a target=\"_blank\" href=\"$www_link\">$www_link</a>\n";
echo "<br/><a target=\"_blank\" href=\"$dmn_link\">$dmn_link</a>\n";
echo "<pre>";
print_r($_COOKIE);
print_r($_SESSION);
}
打印會話在主頁HomeAction
Array
(
[PHPSESSID] => pgguqil2e87h0hn3risov330m3
[_ga] => GA1.2.1895217383.1504264473
[_gid] => GA1.2.1845702714.1504264473
[__zlcmid] => iIgiLC7vUKt6CC
)
Array
(
[__ZF] => Array
(
[_REQUEST_ACCESS_TIME] => 1504271027.5384
)
[userinfo] => Zend\Stdlib\ArrayObject Object
(
[storage:protected] => Array
(
[email] => [email protected]
[password] => e10adc3949ba59abbe56e057f20f883eaa
)
[flag:protected] => 2
[iteratorClass:protected] => ArrayIterator
[protectedProperties:protected] => Array
(
[0] => storage
[1] => flag
[2] => iteratorClass
[3] => protectedProperties
)
)
)
時想使用的子域的數據是不是能夠得到會話數據
功能'eregi_replace()'因爲PHP V5.3棄用,作爲PHP 7.0中移除。請停止使用它。 https://secure.php.net/manual/en/function.eregi-replace.php – edigu