Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

yii2 set cookie

// get the cookie collection (yiiwebCookieCollection) from the "response" component
$cookies = Yii::$app->response->cookies;

// add a new cookie to the response to be sent
$cookies->add(new yiiwebCookie([
    'name' => 'language',
    'value' => 'zh-CN',
]));

// remove a cookie
$cookies->remove('language');
// equivalent to the following
unset($cookies['language']);
Source by www.yiiframework.com #
 
PREVIOUS NEXT
Tagged: #set #cookie
ADD COMMENT
Topic
Name
1+5 =