Tutorial by Examples

To set a cookie i.e. to create it and schedule for sending to the browser you need to create new \yii\web\Cookie class instance and add it to response cookies collection: $cookie = new Cookie([ 'name' => 'cookie_monster', 'value' => 'Me want cookie!', 'expire' => time() + 86...
In order to read a cookie use the following code: $value = \Yii::$app->getRequest()->getCookies()->getValue('my_cookie'); Note: this code allows read cookies that has been set using cookie component (because it signs all cookies by default). Therefore if you add/update cookie using JS c...
Because of security reasons, by default cookies are accessible only on the same domain from which they were set. For example, if you have set a cookie on domain example.com, you cannot get it on domain www.example.com. So if you're planning to use subdomains (i.e. admin.example.com, profile.exampl...
In case of autologin or "remember me" cookie, the same quirks as in case of subdomain cookies are applying. But this time you need to configure user component, setting identityCookie array to desired cookie config. Open you application config file and add identityCookie parameters to use...
Session cookies parameters are important both if you have a need to maintain session while getting from one subdomain to another or when, in contrary, you host backend app under /admin URL and want handle session separately. $config = [ // ... 'components' => [ // ... ...

Page 1 of 1