{"id":323607,"date":"2021-05-23T15:00:17","date_gmt":"2021-05-23T15:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=323607"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=323607","title":{"rendered":"\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043a \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u0443\u043a\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u043a\u0443\u043a\u0438? \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043b\u0438 \u0432\u0430\u043c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e? \u041f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u0443\u043a\u0438 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043d\u044e\u0430\u043d\u0441\u043e\u0432, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u043e\u0438\u0442 \u0437\u043d\u0430\u0442\u044c \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c.<\/p>\n<p>  <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/556742\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/m4\/iy\/rs\/m4iyrsmx3wf7btedcwztbhssnko.jpeg\"><\/a><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2><font color=\"#3AC1EF\">\u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e document.cookie<\/font><\/h2>\n<p>  \u0412\u0437\u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0443\u043a\u0438. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0430\u044f <a href=\"https:\/\/curl.se\/rfc\/cookie_spec.html\">\u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f<\/a> \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f Netscape, \u0441 1994 \u0433\u043e\u0434\u0430. \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u044f Netscape \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0430 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>document.cookie<\/code> \u0432 Netscape Navigator \u0432 1996 \u0433\u043e\u0434\u0443. \u0412\u043e\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u0443\u043a\u0438 \u0438\u0437 \u0442\u0435\u0445 \u0432\u0440\u0435\u043c\u0451\u043d:<\/p>\n<p>  <i><font color=\"#999999\">\u041a\u0443\u043a\u0438 \u2014 \u044d\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0439\u0441\u044f \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0432 \u0444\u0430\u0439\u043b\u0435 cookies.txt.<\/font><\/i><\/p>\n<p>  <a href=\"https:\/\/www.cs.ait.ac.th\/~on\/O\/oreilly\/web\/jscript\/refp_79.htm\">\u0413\u043b\u0430\u0432\u0443<\/a> \u043f\u0440\u043e <code>document.cookie<\/code> \u0434\u0430\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0438\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043d\u0438\u0433\u0438 \u00abJavascript. The Definitive Guide\u00bb, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u0448\u043b\u043e \u0432 \u044f\u043d\u0432\u0430\u0440\u0435 1997 \u0433\u043e\u0434\u0430. \u042d\u0442\u043e \u0431\u044b\u043b\u043e 24 \u0433\u043e\u0434\u0430 \u0442\u043e\u043c\u0443 \u043d\u0430\u0437\u0430\u0434. \u0418 \u043c\u044b \u0432\u0441\u0451 \u0435\u0449\u0451 \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0442\u0435\u043c \u0436\u0435 \u0441\u0442\u0430\u0440\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0443\u043a\u0438 \u0440\u0430\u0434\u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u041a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442?<\/p>\n<h2><font color=\"#3AC1EF\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u0443\u043a\u0438<\/font><\/h2>\n<p>  <\/p>\n<pre><code class=\"javascript\">const cookies = document.cookie; \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 &quot;_octo=GH1.1.123.456; tz=Europe%2FMinsk&quot; on GitHub <\/code><\/pre>\n<p>  \u0414\u0430, \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u0432\u0441\u0451 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f. \u0412 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u043c\u0438\u0441\u044f \u0432 \u043a\u0443\u043a\u0438-\u0444\u0430\u0439\u043b\u0435, \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c\u0438 \u0442\u043e\u0447\u043a\u043e\u0439 \u0441 \u0437\u0430\u043f\u044f\u0442\u043e\u0439.<\/p>\n<p>  \u041a\u0430\u043a \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435? \u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 \u0447\u0430\u0441\u0442\u0438 \u2014 \u0437\u043d\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0442\u0430\u043a \u043e\u043d\u043e \u0438 \u0435\u0441\u0442\u044c:<\/p>\n<pre><code class=\"javascript\">function getCookieValue(name) { \u00a0\u00a0\u00a0\u00a0const cookies = document.cookie.split(';'); \u00a0\u00a0\u00a0\u00a0const res = cookies.find(c =&gt; c.startsWith(name + '=')); \u00a0\u00a0\u00a0\u00a0if (res) { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return res.substring(res.indexOf('=') + 1); \u00a0\u00a0\u00a0\u00a0} } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0443\u0437\u043d\u0430\u0442\u044c \u043e \u0442\u043e\u043c, \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u0442\u0435\u043a\u0430\u0435\u0442 \u0441\u0440\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0438\u0437 \u043a\u0443\u043a\u0438? \u0414\u0430, \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e, \u043d\u0438\u043a\u0430\u043a.<\/p>\n<p>  \u0410 \u043a\u0430\u043a \u0443\u0437\u043d\u0430\u0442\u044c \u0434\u043e\u043c\u0435\u043d, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043a\u0443\u043a\u0438? \u0422\u043e\u0436\u0435 \u043d\u0438\u043a\u0430\u043a.<\/p>\n<p>  \u041f\u0440\u0430\u0432\u0434\u0430, \u0435\u0441\u043b\u0438 \u043d\u0430\u0434\u043e, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c HTTP-\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a <code>Cookie<\/code>.<\/p>\n<h2><font color=\"#3AC1EF\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u0443\u043a\u0438<\/font><\/h2>\n<p>  <\/p>\n<pre><code class=\"javascript\">document.cookie = 'theme=dark'; <\/code><\/pre>\n<p>  \u0412\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u0430\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0443\u043a\u0438 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>theme<\/code>, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>dark<\/code>. \u0425\u043e\u0440\u043e\u0448\u043e. \u0417\u043d\u0430\u0447\u0438\u0442 \u043b\u0438 \u044d\u0442\u043e, \u0447\u0442\u043e <code>document.cookie<\/code> \u2014 \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430. \u041d\u0435\u0442, \u043d\u0435 \u0437\u043d\u0430\u0447\u0438\u0442. \u042d\u0442\u043e \u2014 \u0441\u0435\u0442\u0442\u0435\u0440.<\/p>\n<pre><code class=\"javascript\">document.cookie = 'mozilla=netscape'; <\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0448\u0435\u0442 \u043a\u0443\u043a\u0438 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>theme<\/code>. \u041e\u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u043e\u0432\u044b\u0439 \u043a\u0443\u043a\u0438 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>mozilla<\/code>. \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0434\u0432\u0430 \u043a\u0443\u043a\u0438.<\/p>\n<p>  \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u0440\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0443\u043a\u0438, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u0438\u0441\u0442\u0435\u043a\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430. \u041d\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u0443\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0440\u043e\u043a \u0435\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<pre><code class=\"javascript\">document.cookie = 'browser=ie11; expires=Tue, 17 Aug 2021 00:00:00 GMT'; <\/code><\/pre>\n<p>  \u0414\u0430. \u042d\u0442\u043e \u2014 \u043a\u0430\u043a \u0440\u0430\u0437 \u0442\u043e, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u2014 \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u0430\u0442\u0443 \u0438 \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u043e\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0443\u043a\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 GMT \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u0443\u043a\u0438. \u041b\u0430\u0434\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 JavaScript-\u043a\u043e\u0434\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">const date = new Date(); date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000)); \/\/ \u0437\u0434\u043e\u0440\u043e\u0432\u043e-\u0442\u043e \u043a\u0430\u043a document.cookie = `login=mefody; expires=${date.toUTCString()}; path=\/`; <\/code><\/pre>\n<p>  \u041d\u043e, \u043a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u043e\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0443\u043a\u0438:<\/p>\n<pre><code class=\"javascript\">document.cookie = 'element=caesium; max-age=952001689'; <\/code><\/pre>\n<p>  \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>max-age<\/code> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0440\u043e\u043a \u00ab\u0436\u0438\u0437\u043d\u0438\u00bb \u043a\u0443\u043a\u0438 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442, \u0447\u0435\u043c \u0442\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <code>expires<\/code>.<\/p>\n<p>  \u0418 \u043d\u0435 \u043d\u0430\u0434\u043e \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c \u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u0445 <code>path<\/code> \u0438 <code>domain<\/code>. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043a\u0443\u043a\u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0445\u043e\u0441\u0442\u0430. \u0415\u0441\u043b\u0438 \u043d\u0430\u0434\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u0443\u043a\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u043c\u0435\u043d\u0430 \u2014 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043a\u0443\u043a\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e \u0442\u0430\u043a\u043e\u0433\u043e \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"javascript\">; path=\/; domain=example.com <\/code><\/pre>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u0443\u043a\u0438<\/font><\/h2>\n<p>  <\/p>\n<pre><code class=\"javascript\">document.cookie = 'login=; expires=Thu, 01 Jan 1970 00:00:00 GMT'; <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043a\u0443\u043a\u0438 \u043d\u0430\u0434\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u0442\u0443 \u0438 \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u043e\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0443\u043a\u0438 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u043d\u0438\u0431\u0443\u0434\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0451 \u0442\u043e\u0447\u043d\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0431\u044b \u2014 \u0442\u0443\u0442 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0447\u0430\u043b\u043e \u044d\u043f\u043e\u0445\u0438 Unix.<\/p>\n<h2><font color=\"#3AC1EF\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u0443\u043a\u0438 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441-\u0432\u043e\u0440\u043a\u0435\u0440\u0430\u0445<\/font><\/h2>\n<p>  \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 <code>document.cookie<\/code> \u2014 \u044d\u0442\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0435\u0439 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441-\u0432\u043e\u0440\u043a\u0435\u0440\u0435 \u043d\u0435\u043b\u044c\u0437\u044f.<\/p>\n<h2><font color=\"#3AC1EF\">Cookie Store API<\/font><\/h2>\n<p>  \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0447\u0435\u0440\u043d\u043e\u0432\u0438\u043a \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e API, \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043a\u0443\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0431\u043b\u0435\u0433\u0447\u0438\u0442\u044c \u043d\u0430\u043c \u0436\u0438\u0437\u043d\u044c \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c.<\/p>\n<p>  \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445 \u2014 \u044d\u0442\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 API, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442 \u2014 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c \u043c\u043e\u0436\u043d\u043e, \u043d\u0435 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044f \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a. \u041f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0438 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441-\u0432\u043e\u0440\u043a\u0435\u0440\u0430\u0445.<\/p>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445 \u2014 \u044d\u0442\u043e\u0442 API \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435, \u0447\u0435\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0443\u043a\u0438.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u0443\u043a\u0438<\/font><\/h3>\n<p>  <\/p>\n<pre><code class=\"javascript\">const cookies = await cookieStore.getAll(); const sessionCookies = await cookieStore.getAll({ \u00a0\u00a0\u00a0\u00a0name: 'session_', \u00a0\u00a0\u00a0\u00a0matchType: 'starts-with', }); <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <code>getAll<\/code> \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432, \u0430 \u043d\u0435 \u0441\u0442\u0440\u043e\u043a\u0443. \u0418\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u0438 \u0436\u0434\u0443, \u043a\u043e\u0433\u0434\u0430 \u043f\u044b\u0442\u0430\u044e\u0441\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a.<\/p>\n<pre><code class=\"javascript\">const ga = await cookieStore.get('_ga'); \/** { \u00a0\u00a0\u00a0\u00a0&quot;domain&quot;: &quot;mozilla.org&quot;, \u00a0\u00a0\u00a0\u00a0&quot;expires&quot;: 1682945254000, \u00a0\u00a0\u00a0\u00a0&quot;name&quot;: &quot;_ga&quot;, \u00a0\u00a0\u00a0\u00a0&quot;path&quot;: &quot;\/&quot;, \u00a0\u00a0\u00a0\u00a0&quot;sameSite&quot;: &quot;lax&quot;, \u00a0\u00a0\u00a0\u00a0&quot;secure&quot;: false, \u00a0\u00a0\u00a0\u00a0&quot;value&quot;: &quot;GA1.2.891784426.1616320570&quot; } *\/ <\/code><\/pre>\n<p>  \u0410 \u0432\u043e\u0442 \u2014 \u043f\u0440\u0438\u044f\u0442\u043d\u0430\u044f \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u0441\u0442\u044c. \u041c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0438 \u0434\u0430\u0442\u0443 \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u043e\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0443\u043a\u0438, \u0438 \u0441\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u043e \u0434\u043e\u043c\u0435\u043d\u0435 \u0438 \u043f\u0443\u0442\u0438, \u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0438\u043a\u0430\u043a\u0438\u043c\u0438 \u0445\u0430\u043a\u0430\u043c\u0438.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u0443\u043a\u0438<\/font><\/h3>\n<p>  <\/p>\n<pre><code class=\"javascript\">await cookieStore.set('name', 'value'); <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">await cookieStore.set({ \u00a0\u00a0\u00a0\u00a0name: 'name', \u00a0\u00a0\u00a0\u00a0value: 'value', \u00a0\u00a0\u00a0\u00a0expires: Date.now() + 86400, \u00a0\u00a0\u00a0\u00a0domain: self.location.host, \u00a0\u00a0\u00a0\u00a0path: '\/', \u00a0\u00a0\u00a0\u00a0secure: self.location.protocol === 'https:', \u00a0\u00a0\u00a0\u00a0httpOnly: false, }); <\/code><\/pre>\n<p>  \u041c\u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u044d\u0442\u043e\u0442 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441!<\/p>\n<h3><font color=\"#3AC1EF\">\u258d\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043a\u0443\u043a\u0438<\/font><\/h3>\n<p>  <\/p>\n<pre><code class=\"javascript\">await cookieStore.delete('ie6'); <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u043c\u043e\u0436\u043d\u043e, \u043a\u0430\u043a \u0440\u0430\u043d\u044c\u0448\u0435, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u0442\u0443 \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u043e\u043a\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043a\u0443\u043a\u0438 \u043d\u0430 \u043d\u0435\u043a\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c, \u043d\u043e \u043d\u0435 \u0432\u0438\u0436\u0443 \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a.<\/p>\n<h3><font color=\"#3AC1EF\">\u258d\u0421\u043e\u0431\u044b\u0442\u0438\u044f \u043a\u0443\u043a\u0438<\/font><\/h3>\n<p>  <\/p>\n<pre><code class=\"javascript\">cookieStore.addEventListener('change', (event) =&gt; { \u00a0\u00a0\u00a0\u00a0for (const cookie in event.changed) { \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0console.log(`Cookie ${cookie.name} changed to ${cookie.value}`); \u00a0\u00a0\u00a0\u00a0} }); <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u0443\u043a\u0438, \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u044f\u0441\u044c \u043e\u043f\u0440\u043e\u0441\u043e\u043c <code>document.cookie<\/code>, \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u044e\u0449\u0438\u043c \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a. \u0424\u0430\u043d\u0442\u0430\u0441\u0442\u0438\u043a\u0430!<\/p>\n<h3><font color=\"#3AC1EF\">\u258d\u0421\u0435\u0440\u0432\u0438\u0441-\u0432\u043e\u0440\u043a\u0435\u0440\u044b<\/font><\/h3>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ service-worker.js  await self.registration.cookies.subscribe([ \u00a0\u00a0\u00a0\u00a0{ \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0name: 'cookie-name', \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0url: '\/path-to-track', \u00a0\u00a0\u00a0\u00a0} ]);  self.addEventListener('cookiechange', (event) =&gt; { \u00a0\u00a0\u00a0\u00a0\/\/ \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 }); <\/code><\/pre>\n<p>  <\/p>\n<h2><font color=\"#3AC1EF\">\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u044d\u0442\u0438\u043c API \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441?<\/font><\/h2>\n<p>  \u0425\u043e\u0442\u044f \u044d\u0442\u0438\u043c API \u0443\u0436\u0435 <a href=\"https:\/\/caniuse.com\/cookie-store-api\">\u043c\u043e\u0436\u043d\u043e<\/a> \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u043e \u0442\u0443\u0442 \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0442\u044c \u043e\u0441\u0442\u043e\u0440\u043e\u0436\u043d\u043e\u0441\u0442\u044c. Cookie Store API \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e \u0432 Chrome 87+ (Edge 87+, Opera 73+). \u0412 \u0434\u0440\u0443\u0433\u0438\u0445 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\u0445 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"https:\/\/www.npmjs.com\/package\/cookie-store\">\u043f\u043e\u043b\u0438\u0444\u0438\u043b\u043b\u043e\u043c<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u0440\u0430\u0432\u0434\u0430, \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u0443\u043a\u0438, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c API. \u041f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0438\u0432\u043d\u044b\u0435 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u2014 \u044d\u0442\u043e \u0432\u0435\u0449\u044c.<\/p>\n<p>  \u0418 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0433\u043e API \u0432\u0441\u0451 \u0435\u0449\u0451 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0442\u0430\u0442\u0443\u0441\u0435 \u00abDraft Community Group Report\u00bb. \u041d\u043e \u0435\u0441\u043b\u0438 \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0432\u0430\u0436\u0435\u043d \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u00ab\u043e\u043f\u044b\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u00bb \u2014 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0443\u043a\u0438.<\/p>\n<p>  \u041f\u0440\u043e\u0431\u043e\u0432\u0430\u043b\u0438 \u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043a\u0443\u043a\u0438 \u043f\u043e-\u043d\u043e\u0432\u043e\u043c\u0443?<\/p>\n<p>  <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/557204\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ty\/b7\/fd\/tyb7fdkkt98xbfhc-jlqbuybdda.jpeg\"><\/a><br \/>  <a href=\"http:\/\/ruvds.com\/ru-rub?utm_source=habr&amp;utm_medium=article&amp;utm_campaign=brighttranslate&amp;utm_content=sovremennyj_podxod_k_rabote_s_kuki\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ou\/g5\/kh\/oug5kh6sjydt9llengsiebnp40w.png\"><\/a><\/div>\n<p> \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\/ru\/company\/ruvds\/blog\/556742\/\"> https:\/\/habr.com\/ru\/company\/ruvds\/blog\/556742\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u0412\u044b \u043a\u043e\u0433\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441 \u043a\u0443\u043a\u0438? \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043b\u0438 \u0432\u0430\u043c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e? \u041f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u0432 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u0443\u043a\u0438 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043d\u044e\u0430\u043d\u0441\u043e\u0432, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u043e\u0438\u0442 \u0437\u043d\u0430\u0442\u044c \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c.<\/p>\n<p>  <a href=\"https:\/\/habr.com\/ru\/company\/ruvds\/blog\/556742\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/m4\/iy\/rs\/m4iyrsmx3wf7btedcwztbhssnko.jpeg\"><\/a>  <\/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-323607","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/323607","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=323607"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/323607\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=323607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=323607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=323607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}