{"id":288233,"date":"2018-08-20T09:50:02","date_gmt":"2018-08-20T05:50:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=288233"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=288233","title":{"rendered":"\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 yii1\/yii2"},"content":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/419999\/\" class=\"post__text post__text-html js-mediator-article\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ax\/qo\/vv\/axqovvxw6vehedogcejd1obzehs.jpeg\" alt=\"image\"><\/p>\n<p>  \u042d\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 <a href=\"https:\/\/habr.com\/post\/417677\/\">\u0431\u0435\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u00ab\u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c\u00bb. <\/p>\n<p>  \u041e\u043d\u0430 \u043f\u0440\u043e \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0443 \u043f\u043b\u0430\u0432\u043d\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441 yii1 \u043d\u0430 yii2. \u0415\u0435 \u0441\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0435\u0442\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 yii1 \u0438 \u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0430 yii2 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0434\u043e\u043c\u0435\u043d\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0445\u043e\u0441\u0442\u0435, \u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e, \u043c\u0435\u043b\u043a\u0438\u043c\u0438 \u0448\u0430\u0433\u0430\u043c\u0438 (\u043f\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440\u0430\u043c, \u043c\u043e\u0434\u0443\u043b\u044f\u043c \u0438 \u0442.\u043f.).<\/p>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0431\u044b\u043b\u0430 \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0433\u043e\u043b\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 yii2 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0445\u043e\u0441\u0442\u0435, \u0442.\u0435. \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0435 \u0432\u0435\u0442\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u044f \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443. <\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u0439 \u043f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u044d\u0442\u0430\u043f: \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u0442\u0430. \u042f \u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u043b 2 \u0437\u0430\u0434\u0430\u0447\u0438: \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u0438\u0437\u0430\u0439\u043d \u0438 \u0441\u043a\u0432\u043e\u0437\u043d\u0443\u044e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<p>  \u0414\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0434\u0438\u0437\u0430\u0439\u043d\u0430 \u043e\u0442\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043f\u043e \u0441\u043a\u0443\u0447\u043d\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u043b\u043e, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \/ \u043f\u0435\u0440\u0435\u0432\u0435\u0440\u0441\u0442\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u00ab1 \u0432 1\u00bb. \u041b\u0438\u0447\u043d\u043e \u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u043b \u0441 \u0440\u0435\u0434\u0438\u0437\u0430\u0439\u043d\u043e\u043c. \u0422.\u0435. \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0434\u0438\u0437\u0430\u0439\u043d \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u0441\u044f \u0438 \u0432 \u044d\u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435, \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0435 \u0442\u0443\u043f\u0430\u044f. \u041d\u043e \u0442\u0443\u0442 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u0432\u043e\u0435 \u2013 \u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0443\u0434\u0435\u043b\u044f\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u0438 \u0434\u0438\u0437\u0430\u0439\u043d\u0443, \u043a\u0442\u043e-\u0442\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043b\u044e\u0431\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 backend \u0438 \u043a\u043e\u043d\u0441\u043e\u043b\u044c. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0439, \u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435 \u043f\u0440\u043e\u0439\u0442\u0438 \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f, \u0438 \u043e\u0431\u044a\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439. <\/p>\n<p>  \u0421\u043a\u0432\u043e\u0437\u043d\u0430\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u043d\u044c\u0448\u0435. \u041a\u0430\u043a \u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0442\u0443\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0442\u043a\u0440\u043e\u0432\u0435\u043d\u0438\u0439. \u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0441\u0442\u0430\u0442\u044c\u0438: tutorial \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u0442\u0430\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439, \u0442\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0430\u0434\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0442\u043a\u0430\u043c\u0438. \u0422.\u043a. \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u0430\u043f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435, \u0442\u043e, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0432\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 (\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f, \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f, \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u043e\u043b\u044f \u0438 \u0442.\u043f.) \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0430\u0440\u043e\u043c \u0441\u0430\u0439\u0442\u0435. \u0410 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0442\u043a\u0430 \u043d\u0430 yii2 \u0434\u043e\u043b\u0436\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0438\u0434\u0435\u0442\u044c \u0443\u0436\u0435 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<p>  \u041c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 yii1\/yii2 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0438 \u043d\u0430\u0434\u043e \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u043e\u0434 yii2, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u043c\u043e\u0433 \u0432\u0438\u0434\u0435\u0442\u044c \u0443\u0436\u0435 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422.\u043a. \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0431 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0441\u0435\u0441\u0441\u0438\u0438, \u0442\u043e \u043d\u0430\u0434\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043d\u0430\u0434\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0447\u0442\u0435\u043d\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>  \u0412 \u0441\u0435\u0441\u0441\u0438\u0438 \u043e\u0442 yii1 \u044d\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u0430\u043a-\u0442\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">print_r($_SESSION);  Array (     [34e60d27092d90364d1807021107e5a3__id] =&gt; 123456     [34e60d27092d90364d1807021107e5a3__name] =&gt; tester     [34e60d27092d90364d1807021107e5a3__states] =&gt; Array         (         ) ) <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0443 \u0432\u0430\u0441 \u2013 \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, prefixKey \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 yii1<\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u0432\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0438\u0437 yii1<\/p>\n<pre><code class=\"php\">Yii::app()-&gt;user-&gt;getStateKeyPrefix() Yii::app()-&gt;name Yii::app()-&gt;getBasePath() Yii::app()-&gt;getId() get_class(Yii::app()-&gt;user) <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430 \u043d\u0435\u0439 \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u2014 \u043e\u043d\u0438 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c.<\/p>\n<h2>\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0432 yii2<\/h2>\n<p>  \u0412 Yii2 \u0432\u0435\u0441\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 user (<u>\\yii\\web\\User<\/u>), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438.<\/p>\n<ul>\n<li>\u0412 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0435 <u>getIdentity()<\/u> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <u>renewAuthStatus()<\/u>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0435\u0441\u0441\u0438\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438\u0449\u0435\u0442\u0441\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0443 \u0438\u0437 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <u>$idParam<\/u> (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0442\u0430\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f &#8216;__id&#8217;); <\/li>\n<li>\u0412 \u0441\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 <u>$idParam<\/u> \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e\u0442 <u>app\/model\/User<\/u>).<\/li>\n<\/ul>\n<p>  <i>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e <a href=\"https:\/\/www.yiiframework.com\/doc\/guide\/2.0\/ru\/security-authentication\">\u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u0435<\/a>. <\/i><\/p>\n<p>  \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0432 yii1 \u0441\u0435\u0441\u0441\u0438\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b yii2 \u0438\u0441\u043a\u0430\u043b ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0442\u0435\u043c \u0436\u0435 \u0441\u0430\u043c\u044b\u043c \u043a\u043b\u044e\u0447\u0430\u043c, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u043d \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 yii1.<\/p>\n<p>  <b>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e:<\/b><\/p>\n<p>  1. \u041c\u0435\u043d\u044f\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 user, \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0449\u0438\u0439 \u0437\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u043d\u0430 \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 <u>yii\/web\/User<\/u> \u0432 <u>config\/web.php<\/u><\/p>\n<pre><code class=\"php\">'components' =&gt; [         'user' =&gt; [             'class' =&gt; 'app\\models\\WebUser',             'identityClass' =&gt; 'app\\models\\User',         ], ] <\/code><\/pre>\n<p>  2. \u041a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0432 <u>app\\models\\WebUser<\/u> \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <u>$idParam<\/u>. <\/p>\n<pre><code class=\"php\">public function init() {         \/\/ \u041c\u0435\u043d\u044f\u0435\u043c idParam (\u043a\u043b\u044e\u0447 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f          \/\/ \u043f\u043e\u0438\u0441\u043a \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 \u0441\u0435\u0441\u0441\u0438\u0438)         $this-&gt;idParam = $this-&gt;getIdParamYii1(); }<\/code><\/pre>\n<p>  \u041f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043c\u043d\u043e\u0436\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u0430\u043a-\u0431\u044b \u044d\u043c\u0443\u043b\u0438\u0440\u0443\u044e\u0442 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438\u0437 yii1.<\/p>\n<p>  \u0412\u043e\u043e\u0431\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 <u>_keyPrefix<\/u> (\u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0441\u0440\u0430\u0437\u0443 <u>idParam<\/u>) \u0438\u0437 yii1 \u0438 \u043d\u0435 \u044d\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044e, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u00ab\u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u0443\u044e \u0444\u0438\u0433\u043d\u044e\u00bb.<\/p>\n<p>  \u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e _keyPrefix \u0432 yii1 \u043f\u043e\u0447\u0442\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439. \u041e\u043d \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043c\u0435\u0441\u0442\u0435 \u0438\u043c\u0435\u043d\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 user \u0438 \u043e\u0442 ID \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043c\u0435\u0441\u0442\u0430 \u043c\u0435\u0441\u0442\u0430 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0435\u0433\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f. <\/p>\n<pre><code class=\"php\">\/\/ \u0422\u0430\u043a \u0432 yii1 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 _keyPrefix $this-&gt;_keyPrefix = md5('Yii.'.get_class($this).'.'.Yii::app()-&gt;getId());  \/\/ \u0410 \u0442\u0430\u043a - ID \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f $this-&gt;_id=sprintf('%x',crc32($this-&gt;getBasePath().$this-&gt;name)); <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0442\u043e \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f _keyPrefix \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u044b. \u041d\u043e \u0443 \u043c\u0435\u043d\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0448\u0438\u0440\u043e\u043a\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 user (app\\models\\WebUser)<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\"> namespace app\\models;  use yii\\web\\User;  class WebUser extends User {      \/**      * \u041e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 cookies \u0432 yii2,      *  \u043f\u043e\u043a\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u0432 yii1       *\/     public $autoRenewCookie = false;      \/**      * _keyPrefix \u043f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438 \u0441 CWebUser \u0438\u0437 Yii1      *\/     private $_keyPrefix;      \/**      * \u041d\u0430\u0431\u043e\u0440 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043e\u0442 Yii1, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438     *\/     private $paramsYii1 = [         \/\/ \u0418\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 user \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 Yii1         'classUserComponent' =&gt; 'CWebUser',         \/\/ ID \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Yii1          \/\/ \u041c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 Yii::app()-&gt;getId()         'appId' =&gt; '',         \/\/ \u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u043a\u043e\u043d\u0444\u0438\u0433\u0430 Yii1         'appName' =&gt; 'My Web Application',         \/\/ \u041e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e yii1 \u043e\u0442 \\Yii::getAlias('@app')         'relPath' =&gt; '..\/htdocs\/protected',     ];      public function init() {         \/\/ \u041c\u0435\u043d\u044f\u0435\u043c idParam (\u043a\u043b\u044e\u0447 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f          \/\/ \u043f\u043e\u0438\u0441\u043a \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432 \u0441\u0435\u0441\u0441\u0438\u0438)         $this-&gt;idParam = $this-&gt;getIdParamYii1();     }  } <\/code><\/pre>\n<p>  \u0418 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a \u043d\u0435\u043c\u0443 \u0436\u0435 (WebUser). <i>\u041e\u0442\u0434\u0435\u043b\u0438\u043b \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430.<\/i><\/p>\n<pre><code class=\"php\">\/**  * \u041a\u043b\u044e\u0447 \u0434\u043b\u044f \u0441\u0435\u0441\u0441\u0438\u0438 \u0438\u0437 Yii1, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f *\/ public function getIdParamYii1() {     return $this-&gt;getStateKeyPrefix() . '__id'; }  \/** * \u041c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0438\u0437 Yii 1 * @return string  *\/ public function getStateKeyPrefix() {     if ($this-&gt;_keyPrefix !== null)         return $this-&gt;_keyPrefix;      $class = $this-&gt;paramsYii1['classUserComponent'];     return $this-&gt;_keyPrefix = md5('Yii.' . $class . '.' . $this-&gt;getAppIdYii1());      }  \/** * \u042d\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 getId() \u0438\u0437 CApplication * @return string ID \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Yii1 *\/ public function getAppIdYii1() {      if ($this-&gt;paramsYii1['appId'])         return $this-&gt;paramsYii1['appId'];      return $this-&gt;paramsYii1['appId'] = sprintf('%x', crc32($this-&gt;getBasePathYii1() . $this-&gt;paramsYii1['appName']));  }  \/** * @return string \u041f\u0443\u0442\u044c \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e Yii1 *\/ private function getBasePathYii1() {      $basePath = realpath(\\Yii::getAlias('@app') . DIRECTORY_SEPARATOR . $this-&gt;paramsYii1['relPath']);      if (!$basePath)        throw new InvalidConfigException('basePath \u0434\u043b\u044f yii1 \u0437\u0430\u0434\u0430\u043d \u043d\u0435\u0432\u0435\u0440\u043d\u043e.');      return $basePath; } <\/code><\/pre>\n<p>  <i>\u0422\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447\u0438 &#171;<u>\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0430\u0442 \u0441\u0435\u0441\u0441\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430<\/u>&#187; \u0434\u0435\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0436\u043d\u0435\u043d\u043d\u0430\u044f, \u043d\u043e \u043e\u043d\u0438 \u043f\u0440\u0438\u0433\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u043d\u0438\u0436\u0435. <\/i><\/p><\/div>\n<\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432 \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0442\u043a\u0435 \u043d\u0430 yii2 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0443\u0437\u043d\u0430\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 yii1. \u0412 \u0438\u0434\u0435\u0430\u043b\u0435, \u043d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0434\u043e \u0431\u044b \u0438 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u043a\u043e\u043b\u044c\u0437\u043a\u0438\u0439 \u043f\u0443\u0442\u044c.<\/p>\n<h2>Login \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 yii2<\/h2>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d \u0444\u043e\u0440\u043c\u0430\u0442 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432 \u0441\u0435\u0441\u0441\u0438\u0438 ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0434\u0430\u0436\u0435 \u00ab\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u00bb \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 Login \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0447\u0435\u0440\u0435\u0437 yii2.<\/p>\n<p>  <i>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443 login-\u0430 \u043d\u0430 yii2 \u0432 \u0431\u043e\u0435\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u0431\u0435\u0437 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0444\u043e\u0440\u043c\u044b \u043d\u0430 yii1 \u0441\u0447\u0438\u0442\u0430\u044e \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c, \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0447\u0438\u043c \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0439.<\/i><\/p>\n<p>  \u0422.\u043a. \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u043a\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0438 \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u043e\u043b\u0435\u0439 \u0443 \u043d\u0430\u0441 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432 \u0443ii1, \u0442\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0447\u0435\u0433\u043e login \u0447\u0435\u0440\u0435\u0437 yii2 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043c\u0435\u0442\u043e\u0434 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0440\u043e\u043b\u044f \u0432 yii2 \u043c\u043e\u0433 \u043f\u043e\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043e \u0432 Yii1.<\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u044e\u0442 \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0432 Yii2 \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f User \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u0442 \u043f\u0430\u0440\u043e\u043b\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">public function validatePassword($password) {     return \\Yii::$app-&gt;getSecurity()-&gt;validatePassword($password, $this-&gt;password); } <\/code><\/pre>\n<p>  \u0422\u043e, \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <u>validatePassword($password, $hash)<\/u> \u0438\u0437 <u>yii\\base\\Security<\/u> (Yii2)<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">validatePassword()<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">public function validatePassword($password, $hash)     {         if (!is_string($password) || $password === '') {             throw new InvalidArgumentException('Password must be a string and cannot be empty.');         }         if (!preg_match('\/^\\$2[axy]\\$(\\d\\d)\\$[\\.\\\/0-9A-Za-z]{22}\/', $hash, $matches)             || $matches[1] &lt; 4             || $matches[1] &gt; 30         ) {             throw new InvalidArgumentException('Hash is invalid.');         }         if (function_exists('password_verify')) {             return password_verify($password, $hash);         }         $test = crypt($password, $hash);         $n = strlen($test);         if ($n !== 60) {             return false;         }         return $this-&gt;compareString($test, $hash);     } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  \u0410 \u0435\u0441\u043b\u0438 \u043d\u0430 Yii1 \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0430\u0440\u043e\u043b\u044f \u0432 \u043c\u043e\u0434\u0435\u043b\u0438 User \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">public function hashPassword($password) {         return CPasswordHelper::hashPassword($password); } <\/code><\/pre>\n<p>  \u0422\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0441 <u>verifyPassword($password, $hash)<\/u> \u0438\u0437 <u>yii\\framework\\utils\\CPasswordHelper<\/u><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">hashPassword()<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">public static function hashPassword($password,$cost=13) {     self::checkBlowfish();     $salt=self::generateSalt($cost);     $hash=crypt($password,$salt);      if(!is_string($hash) || (function_exists('mb_strlen') ? mb_strlen($hash, '8bit') : strlen($hash))&lt;32)         throw new CException(Yii::t('yii','Internal error while generating hash.'));      return $hash; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044e \u0432 <u>validatePassword()<\/u> \u0438\u0437 <u>app\\model\\User<\/u>. <\/p>\n<p>  \u0418\u0437 \u043a\u043e\u0440\u043e\u0431\u043e\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u0444\u0440\u0435\u0439\u043c\u043e\u0440\u043a\u0430 \u0445\u0435\u0448\u0438 \u043f\u0430\u0440\u043e\u043b\u0435\u0439 Yii1\/Yii2 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b. \u041d\u043e \u044d\u0442\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u044b \u0443 \u0432\u0430\u0441 \u0438\u043b\u0438 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c. \u0421 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\u044e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u0438, \u043c\u0435\u0442\u043e\u0434\u044b \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 Yii1 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0432 \u043d\u043e\u0432\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043d\u0430 Yii2 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f.<\/p>\n<h2>\u0410\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u043d \u0432 Yii2 \u043f\u043e \u043a\u0443\u043a\u0430\u043c \u0438\u0437 yii1<\/h2>\n<p>  <\/p>\n<blockquote><p>\u0420\u0430\u0437 \u0432\u0435\u0442\u043a\u0430 \u043d\u0430 Yii2 \u0443\u0436\u0435 \u0443\u043c\u0435\u0435\u0442 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043e\u0442 Yii1, \u0442\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u043d \u043f\u043e \u043a\u0443\u043a\u0430\u043c?  <\/p><\/blockquote>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0430\u0441 \u043f\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u0442 \u0442\u0430\u043a\u0430\u044f \u043c\u044b\u0441\u043b\u044c, \u0442\u043e \u044f \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043e\u0442 \u043d\u0435\u0435 \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f. \u041d\u0435 \u0432\u0438\u0436\u0443 \u043d\u0438 \u043e\u0434\u043d\u043e\u0439 \u0432\u0435\u0441\u043a\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u043d \u043d\u0430 Yii2 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043d\u0430 \u044d\u0442\u0443 \u0432\u0435\u0442\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 (\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c). \u0422.\u0435. \u0438\u043c\u0435\u044e \u0432\u0432\u0438\u0434\u0443 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439: <\/p>\n<p>  <i>\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 Yii1, \u043d\u043e \u0432\u0435\u0442\u043a\u0430 Yii2 \u0434\u043e\u043b\u0436\u043d\u0430 \u0443\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u043d \u043f\u043e \u043a\u0443\u043a\u0430\u043c, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u043c \u0432 Yii1. <br \/>  <\/i><br \/>  \u0415\u0441\u043b\u0438 \u0447\u0435\u0441\u0442\u043d\u043e, \u044d\u0442\u043e \u043e\u0442\u043a\u0440\u043e\u0432\u0435\u043d\u043d\u043e\u0435 \u0438\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435. \u041b\u0435\u0433\u043a\u043e \u0438 \u0438\u0437\u044f\u0449\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0438 \u043a\u0430\u043a \u0440\u0430\u0437 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0433\u0440\u0430\u043d\u044c \u043c\u0435\u0436\u0434\u0443 \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0439 \u0438 \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u043f\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u0438\u0437\u043e\u0431\u0440\u0435\u0442\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u043e\u0432.<\/p>\n<p>  \u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u043e\u0431\u043e\u0438\u0445 \u0432\u0435\u0442\u043a\u0430\u0445 Yii \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u043f\u043e\u0434\u0434\u0435\u043b\u043a\u0438 \u043a\u0443\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043b\u043e\u0436\u043d\u043e\u0432\u0430\u0442\u043e.<\/p>\n<ul>\n<li>\u0412 Yii2 \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b: user (<u>\\yii\\web\\User<\/u>), <u>Request<\/u>, <u>Security<\/u> + <u>CookieCollection<\/u><\/li>\n<li>\u0412 Yii1: <u>CWebUser<\/u>, <u>CHttpRequest<\/u>, <u>CSecurityManager<\/u>, <u>CStatePersister<\/u>, <u>CCookieCollection<\/u><\/li>\n<\/ul>\n<p>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0441\u043b\u0443\u0447\u0430\u0438 \u0431\u044b\u0432\u0430\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u0435. \u041d\u0438\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u043d \u0441 \u0432\u0435\u043b\u043e\u0441\u0438\u043f\u0435\u0434\u0430\u043c\u0438.<\/p>\n<p>  \u0412 yii2 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <u>getIdentityAndDurationFromCookie()<\/u> \u0438\u0437 <u>\\yii\\web\\User<\/u>. \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0430 \u043d\u0443\u0436\u043d\u0430\u044f \u043a\u0443\u043a\u0430:<\/p>\n<pre><code class=\"php\">$value = Yii::$app-&gt;getRequest()-&gt;getCookies()-&gt;getValue($this-&gt;identityCookie['name']);<\/code><\/pre>\n<p>  \u041d\u043e \u0435\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u0442.\u043a. \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f <u>Yii::$app-&gt;getRequest()-&gt;getCookies()<\/u> \u0431\u0443\u0434\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0439, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 <u>Request <\/u> cookies \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0441 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0435\u0439 \u0432 <u>loadCookies()<\/u> \u0438, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0435\u0435 \u043d\u0435 \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0442.<\/p>\n<p>  \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u043e\u0440\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0432 <u>getIdentityAndDurationFromCookie()<\/u>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a:<\/p>\n<ol>\n<li>\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u0443\u044e cookie \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u0441\u0443\u043f\u0435\u0440\u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e $_COOKIE, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 <s>\u043b\u043e\u043c\u0430\u0442\u044c<\/s> \u0430\u0434\u0430\u043f\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 cookies.\n<p>  \u0418\u043c\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u043a\u0443\u043a\u0438 \u2014 \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 _keyPrefix, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0443\u043c\u0435\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c (\u0438\u043b\u0438 \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u0435\u043d\u044f\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 <u>$identityCookie<\/u> \u0432 <u>init()<\/u>.  <\/li>\n<li>\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u043a\u0443\u043a\u0443 \u00ab\u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e, \u043a\u0430\u043a \u0432 yii1\u00bb. \u041a\u0430\u043a \u0443\u0433\u043e\u0434\u043d\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044f \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043b \u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438\u0437 <u>CSecurityManager<\/u>.<\/li>\n<\/ol>\n<p>  \u041d\u0438\u0436\u0435, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u043e\u0434.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 app\/models\/WebUser<\/b><\/p>\n<div class=\"spoiler_text\">1. \u0418\u043c\u044f identityCookie \u043a\u0443\u043a\u0438 \u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 yii1<\/p>\n<pre><code class=\"php\">public function init() {     $this-&gt;idParam = $this-&gt;getIdParamYii1();      \/\/ \u041c\u0435\u043d\u044f\u0435\u043c \u0438\u043c\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u043a\u0443\u043a\u0438     $this-&gt;identityCookie = ['name' =&gt; $this-&gt;getStateKeyPrefix()]; } <\/code><\/pre>\n<p>  2. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0449\u0435 \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430<\/p>\n<pre><code class=\"php\">     \/**  * \u041f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434        *\/ protected function getIdentityAndDurationFromCookie() {      $id = $this-&gt;getIdIdentityFromCookiesYii1();      if (!$id) {         return null;     }      $class = $this-&gt;identityClass;     $identity = $class::findOne($id);     if ($identity !== null) {         return ['identity' =&gt; $identity, 'duration' =&gt; 0];     }      return null; }  \/** * \u0412\u044b\u0442\u0430\u0449\u0438\u0442\u044c ID identity \u0438\u0437 cookies, \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0432 yii1 *  * @return null|integer \u0412\u043e\u0437\u0440\u0430\u0449\u0430\u0435\u0442 ID \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0435\u0441\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e \u0438\u043b\u0438 null *\/ protected function getIdIdentityFromCookiesYii1() {      if (!isset($_COOKIE[$this-&gt;identityCookie['name']]))         return null;      $cookieValue = $_COOKIE[$this-&gt;identityCookie['name']];      \/\/ Cookies \u0432 yii1 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u044b, \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u043c     $utilSecurity = new UtilYii1Security($this-&gt;getBasePathYii1());     $data = $utilSecurity-&gt;validateData($cookieValue);      if ($data === false) {        return null;     }      $data = @unserialize($data);      if (is_array($data) &amp;&amp; isset($data[0], $data[1], $data[2], $data[3])) {         list($id, $name, $duration, $states) = $data;         return $id;     }      return null; } <\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<p>  \u0412 \u043a\u043e\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 <u>UtilYii1Security<\/u> \u2013 \u044d\u0442\u043e \u043c\u043e\u0434\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043f\u0438\u043f\u0430\u0441\u0442 \u043d\u0443\u0436\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0437 <u>CSecurityManager<\/u>, \u0447\u0442\u043e\u0431\u044b \u0441 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0431\u044b\u043b\u043e \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b, \u043d\u043e \u0441 \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f\u043c\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 <u>CSecurityManager<\/u> \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 HMAC (hash-based message authentication code), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 php \u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u044f mbstring. \u041d\u043e \u0442.\u043a. \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e yii1 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0442\u043e\u043c \u0436\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438, \u0447\u0442\u043e \u0438 yii2, \u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442\u0441\u044f \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043a\u043e\u0434 \u0442\u043e\u0436\u0435.<\/p>\n<p>  \u0422.\u043a. \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u044f\u0441\u043d\u043e, \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u044f\u0432\u043d\u044b\u0439 \u043a\u043e\u0441\u0442\u044b\u043b\u044c, \u0442\u043e \u0438 \u043d\u0435 \u043d\u0430\u0434\u043e \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u043f\u0440\u0438\u0434\u0430\u0432\u0430\u0442\u044c \u0431\u043b\u0430\u0433\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u00ab\u0437\u0430\u0442\u043e\u0447\u0438\u0442\u044c\u00bb \u0435\u0433\u043e \u043f\u043e\u0434 \u0441\u0432\u043e\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">UtilYii1Security.php<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php  namespace app\\components;  \/*  * \u042d\u043c\u0443\u043b\u044f\u0446\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432 CSecurityManager \u0438\u0437 Yii1,   * \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0434\u043b\u044f \u0441\u043a\u0432\u043e\u0437\u043d\u043e\u0439 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 *   *\/  use yii\\base\\Exception; use yii\\base\\Model; use yii\\base\\InvalidConfigException;  class UtilYii1Security {      \/**      * \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430, \u043a\u0430\u043a \u0432 yii1      *\/     const STATE_VALIDATION_KEY = 'Yii.CSecurityManager.validationkey';      \/**      * \u0410\u043b\u0433\u043e\u0440\u0438\u0438\u043c \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432 yii1      *\/     public $hashAlgorithm = 'sha1';      \/**      * \u041a\u043b\u044e\u0447 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 cookies      *\/     private $_validationKey;      \/**      * \u041f\u0443\u0442\u044c \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e Yii1      *\/     private $basePath;      \/**      * \u041f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0432 yii1      *\/     private $stateFile;      \/**      * @param string $basePath - \u043f\u0443\u0442\u044c \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e Yii1      * \u041d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u0443\u0442\u0438 \u043a \u0444\u0430\u0439\u043b\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 stateFile      *\/     public function __construct($basePath) {         $this-&gt;basePath = $basePath;          $this-&gt;stateFile = $this-&gt;basePath . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR . 'state.bin';          if (!realpath($this-&gt;stateFile))             throw new InvalidConfigException('\u041f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043d\u0435\u0432\u0435\u0440\u0435\u043d');     }      public function validateData($data, $key = null) {          if (!is_string($data))             return false;          $len = $this-&gt;strlen($this-&gt;computeHMAC('test'));         if ($this-&gt;strlen($data) &gt;= $len) {             $hmac = $this-&gt;substr($data, 0, $len);             $data2 = $this-&gt;substr($data, $len, $this-&gt;strlen($data));             return $this-&gt;compareString($hmac, $this-&gt;computeHMAC($data2, $key)) ? $data2 : false;         } else             return false;     }      public function computeHMAC($data, $key = null) {         if ($key === null)             $key = $this-&gt;getValidationKey();          return hash_hmac($this-&gt;hashAlgorithm, $data, $key);     }      public function getValidationKey() {         if ($this-&gt;_validationKey !== null)             return $this-&gt;_validationKey;          if (($key = $this-&gt;loadStateValidationKey(self::STATE_VALIDATION_KEY)) !== null) {             $this-&gt;_validationKey = $key;         }         return $this-&gt;_validationKey;     }      \/\/ \u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c validationKey \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 Yii1     private function loadStateValidationKey($key) {          $content = $this-&gt;loadState();          if ($content) {             $content = unserialize($content);             if (isset($content[$key]))                 return $content[$key];         }          return false;     }      \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 Yii1     protected function loadState() {          $filename = $this-&gt;stateFile;          $file = fopen($filename, \"r\");         if ($file &amp;&amp; flock($file, LOCK_SH)) {             $contents = @file_get_contents($filename);             flock($file, LOCK_UN);             fclose($file);             return $contents;         }         return false;     }      public function compareString($expected, $actual) {         $expected .= \"\\0\";         $actual .= \"\\0\";         $expectedLength = $this-&gt;strlen($expected);         $actualLength = $this-&gt;strlen($actual);         $diff = $expectedLength - $actualLength;         for ($i = 0; $i &lt; $actualLength; $i++)             $diff |= (ord($actual[$i]) ^ ord($expected[$i % $expectedLength]));         return $diff === 0;     }      private function strlen($string) {         return mb_strlen($string, '8bit');     }      private function substr($string, $start, $length) {         return mb_substr($string, $start, $length, '8bit');     }  }  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<h2>\u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439<\/h2>\n<p>  \u041f\u0440\u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 yii1 \u043d\u0430 yii2 \u0432 \u0447\u0430\u0441\u0442\u0438 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u044f \u043f\u0440\u0438\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u043b\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438:<\/p>\n<ol>\n<li>\u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u0443\u044e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u0435\u0436\u0434\u0443 \u0432\u0435\u0442\u043a\u0430\u043c\u0438.<br \/>  \u0422.\u0435. \u0447\u0442\u043e\u0431\u044b \u0432\u0435\u0442\u043a\u0430 \u043d\u0430 yii2 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 yii1. \u042d\u0442\u043e \u0431\u044b\u0441\u0442\u0440\u043e, \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e.  <\/li>\n<li>\u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e (login \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f) \u0438\u0437 yii1 \u0432 yii2.<br \/>  \u041e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0432 \u0435\u0435 \u0432 \u0441\u0442\u0430\u0440\u043e\u0439 \u0432\u0435\u0442\u043a\u0435. \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u0447\u0442\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u043d \u043f\u043e \u043a\u0443\u043a\u0430\u043c, \u0442.\u043a. \u043a\u0443\u043a\u0438 \u043e\u0442 yii1 \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442, \u0430 \u043d\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043d\u0430 yii2 \u0435\u0449\u0435 \u043c\u0430\u043b\u043e.<\/li>\n<li>\u041f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 yii2 \u0445\u043e\u0442\u044f \u0431\u044b \u0433\u043b\u0430\u0432\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u0430\u0439\u0442\u0430<br \/>  \u0427\u0442\u043e\u0431\u044b \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u043d \u043f\u043e \u043d\u043e\u0432\u044b\u043c \u043a\u0443\u043a\u0430\u0445, \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c\u044b\u043c \u0432 yii2.<br \/>  \u041d\u0430\u043b\u0438\u0447\u0438\u0435 \u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u043d\u0430 \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0430\u0441\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043f\u0430\u0432\u0448\u0438\u0439 \u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u043d \u043d\u0430 \u043f\u0440\u0435\u0436\u043d\u0435\u0439 \u0432\u0435\u0442\u043a\u0435.  <\/li>\n<li>\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0442\u043e\u0431\u044b yii1 \u043f\u043e\u043d\u0438\u043c\u0430\u043b \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 yii2.<br \/>  \u0427\u0435\u0440\u0435\u0437 \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0441\u0435\u0441\u0441\u0438\u0438.  <\/li>\n<li>\u041f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0432 yii2 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<br \/>  \u041f\u0435\u0440\u0435\u043d\u043e\u0441 \u043d\u0430\u0434\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e \u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0445\u0435\u0448\u0435\u0439 \u043f\u0430\u0440\u043e\u043b\u0435\u0439. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0445\u0435\u0448\u0430 \u0438\u043b\u0438 \u0432\u0432\u0435\u0441\u0442\u0438 \u043d\u043e\u0432\u044b\u0439, \u043d\u043e \u0442\u0430\u043a \u0447\u0442\u043e\u0431\u044b login \u043f\u043e\u043d\u0438\u043c\u0430\u043b \u043e\u0431\u0430 \u0442\u0438\u043f\u0430.<\/li>\n<li>\u041f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0441\u0430\u0439\u0442\u0430 \u0441\u0435\u0440\u0432\u0438\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0435\u0442 yii2 \u00ab\u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438\u00bb.<br \/>  \u0418\u043c\u0435\u044e \u0432\u0432\u0438\u0434\u0443 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 <u>IdentityInterface<\/u> \u0443 <u>User<\/u>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e \u0442\u043e\u043a\u0435\u043d\u0443, \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u043e\u043b\u044f \u0438 \u0442.\u043f. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0443 \u0432\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f \u043e\u0431\u0432\u044f\u0437\u043a\u0430, \u043d\u043e \u0432\u0434\u0440\u0443\u0433 \u043d\u0435\u0442? \u0422\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0443\u0441\u0438\u043b\u0438\u044f\u043c\u0438.\n<p>  \u0415\u0441\u043b\u0438 \u00ab\u0434\u0430\u00bb, \u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f (\u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f) \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u0430\u0431\u0438\u043d\u0435\u0442 \u0432 yii2 (\u0445\u043e\u0442\u044f \u0431\u044b \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e).<br \/>  \u0415\u0441\u043b\u0438 \u00ab\u043d\u0435\u0442\u00bb, \u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043f\u0440\u043e \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u043b\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430 (\u0434\u0430\u0436\u0435 \u0431\u0435\u0437 \u043d\u043e\u0432\u0438\u043d\u043e\u043a).  <\/li>\n<\/ol>\n<h4>PS:<\/h4>\n<p>  \u0422\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u0438 \u043d\u0435 \u0432\u0441\u0435 \u0438\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c. <\/p>\n<p>  \u041e\u043d\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0435 \u0441 \u0446\u0435\u043b\u044c\u044e \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u2014 \u00ab\u0434\u0435\u043b\u0430\u0439 \u043a\u0430\u043a \u044f\u00bb. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0435\u043b\u0430\u0442\u044c \u0432 yii2 \u0430\u0432\u0442\u043e\u043b\u043e\u0433\u0438\u043d \u043f\u043e \u043a\u0443\u043a\u0430\u043c \u0438\u0437 yii1 \u2014 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e, \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0435 \u0445\u043e\u0440\u043e\u0448\u043e (\u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0441\u0442\u044b\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0447\u0435\u043c-\u0442\u043e \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d).<\/p>\n<p>  \u041d\u043e \u044f \u0443\u0436\u0435 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b \u043d\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0438 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e, \u0433\u043b\u044f\u0434\u044f \u043d\u0430 \u043c\u043e\u0439 \u043e\u043f\u044b\u0442, \u0435\u0433\u043e \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442.<\/p><\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/post\/419999\/\"> https:\/\/habr.com\/post\/419999\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div data-io-article-url=\"https:\/\/habr.com\/post\/419999\/\" class=\"post__text post__text-html js-mediator-article\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ax\/qo\/vv\/axqovvxw6vehedogcejd1obzehs.jpeg\" alt=\"image\"><\/p>\n<p>  \u042d\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 <a href=\"https:\/\/habr.com\/post\/417677\/\">\u0431\u0435\u0437 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442 \u00ab\u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c\u00bb. <\/p>\n<p>  \u041e\u043d\u0430 \u043f\u0440\u043e \u043c\u0435\u0442\u043e\u0434\u0438\u043a\u0443 \u043f\u043b\u0430\u0432\u043d\u043e\u0439 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441 yii1 \u043d\u0430 yii2. \u0415\u0435 \u0441\u0443\u0442\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u0435\u0442\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0430 yii1 \u0438 \u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043d\u0430 yii2 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0434\u043e\u043c\u0435\u043d\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0445\u043e\u0441\u0442\u0435, \u0430 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e\u0441\u0442\u0435\u043f\u0435\u043d\u043d\u043e, \u043c\u0435\u043b\u043a\u0438\u043c\u0438 \u0448\u0430\u0433\u0430\u043c\u0438 (\u043f\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u0440\u0430\u043c, \u043c\u043e\u0434\u0443\u043b\u044f\u043c \u0438 \u0442.\u043f.).<\/p>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0431\u044b\u043b\u0430 \u043f\u0440\u043e \u0442\u043e, \u043a\u0430\u043a \u0433\u043e\u043b\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 yii2 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u043c \u0445\u043e\u0441\u0442\u0435, \u0442.\u0435. \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u0435 \u0432\u0435\u0442\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u043d\u0435 \u043c\u0435\u0448\u0430\u044f \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443. <\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u044b\u0439 \u043f\u0441\u0438\u0445\u043e\u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u044d\u0442\u0430\u043f: \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0441\u0442\u0430\u0440\u0442\u0430. \u042f \u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u043b 2 \u0437\u0430\u0434\u0430\u0447\u0438: \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0434\u0438\u0437\u0430\u0439\u043d \u0438 \u0441\u043a\u0432\u043e\u0437\u043d\u0443\u044e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.<\/p>\n<p>  \u0414\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0434\u0438\u0437\u0430\u0439\u043d\u0430 \u043e\u0442\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u043e\u0435 \u043c\u0435\u0441\u0442\u043e \u043f\u043e \u0441\u043a\u0443\u0447\u043d\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u043b\u043e, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \/ \u043f\u0435\u0440\u0435\u0432\u0435\u0440\u0441\u0442\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u00ab1 \u0432 1\u00bb. \u041b\u0438\u0447\u043d\u043e \u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u043b \u0441 \u0440\u0435\u0434\u0438\u0437\u0430\u0439\u043d\u043e\u043c. \u0422.\u0435. \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438 \u0434\u0438\u0437\u0430\u0439\u043d \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u043b\u0441\u044f \u0438 \u0432 \u044d\u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435, \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0435 \u0442\u0443\u043f\u0430\u044f. \u041d\u043e \u0442\u0443\u0442 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u0432\u043e\u0435 \u2013 \u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0443\u0434\u0435\u043b\u044f\u044e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u0438 \u0434\u0438\u0437\u0430\u0439\u043d\u0443, \u043a\u0442\u043e-\u0442\u043e \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442, \u043b\u044e\u0431\u0438\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 backend \u0438 \u043a\u043e\u043d\u0441\u043e\u043b\u044c. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0435\u043d\u0438\u0439, \u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0435 \u043f\u0440\u043e\u0439\u0442\u0438 \u2014 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f, \u0438 \u043e\u0431\u044a\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439. <\/p>\n<p>  \u0421\u043a\u0432\u043e\u0437\u043d\u0430\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u043d\u044c\u0448\u0435. \u041a\u0430\u043a \u0438 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0442\u0443\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u0442\u043a\u0440\u043e\u0432\u0435\u043d\u0438\u0439. \u0425\u0430\u0440\u0430\u043a\u0442\u0435\u0440 \u0441\u0442\u0430\u0442\u044c\u0438: tutorial \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442 \u0442\u0430\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u0430\u0448 \u0441\u043b\u0443\u0447\u0430\u0439, \u0442\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-288233","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288233","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=288233"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/288233\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=288233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=288233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=288233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}