public function getCookieName()
{
return md5('model_Widget_' . $this->id);
}
public function getCookie()
{
$cookieName = $this->cookieName;
$value = null;
$cookies = Yii::$app->request->cookies;
if (!$cookies->has($cookieName)) {
$value = 'test';
Yii::$app->response->cookies->add(new \yii\web\Cookie([
'name' => $cookieName,
'value' => $value,
'expire' => time() + 3600 * 24 * 365 * 10
]));
} else {
$value = $cookies->get($cookieName);
}
return $value;
}