我使用yii2框架登录,并使用yii2的java API收费端保存了Cookie令牌,但未将Cookie保存在网络浏览器中正常工作。唯一的问题是移动浏览器面临同样的问题吗? 2在移动浏览器中两次登录客户端比cookie起作用。这个问题怎么解决?
ActionSetCookie
public function actionSetCookie() {
$cookies = Yii::$app->response->cookies;
$cookies->add(new \yii\web\Cookie([
'name' => 'abc',
'value' => 'xyz',
'expire' => time() + 86400 * 365,
]));
echo 'Cookie set!'
;}
ActionGetCookie
public function actionGetCookie() {
$cookies1 = Yii::$app->request->cookies;
if ($cookies1->has('abc'))
$cookieValue = $cookies1->getValue('abc');
echo 'value : '.$cookieValue;
}