{"id":397529,"date":"2024-06-29T13:30:32","date_gmt":"2024-06-29T13:30:32","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=397529"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=397529","title":{"rendered":"<span>Node.js \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044f Cookie<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/post_images\/8c5\/51b\/d1d\/8c551bd1de92be5e0d526a22355c0bc9.png\" width=\"444\" height=\"320\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8c5\/51b\/d1d\/8c551bd1de92be5e0d526a22355c0bc9.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044f Cookie, \u0433\u0434\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c<em>.<\/em> \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0445\u0438\u0449\u0435\u043d\u0438\u044f \u0447\u0443\u0436\u0438\u0445 \u043a\u0443\u043a\u0438, \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0441\u0432\u043e\u0438\u0445 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h2>\u0414\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044f Cookie?<\/h2>\n<p>\u041a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Cookie \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0442 <strong><em>a.com<\/em><\/strong> \u0434\u043e <strong><em>b.com<\/em><\/strong><\/p>\n<h3>\u0413\u0434\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c?<\/h3>\n<p>\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u0430\u0442\u044c \u043d\u0430\u0448\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u0438 \u0441\u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0443 \u0441\u0435\u0431\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u0430\u043d\u043d\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0433\u0435\u043e\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u043b\u044e\u0431\u0430\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438. \u0422\u0430\u043a\u0436\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 &#171;\u0432\u0435\u0441\u0442\u0438&#187; \u0435\u0433\u043e \u043e\u0442 \u0441\u0430\u0439\u0442\u0430 \u043a \u0441\u0430\u0439\u0442\u0443, \u0447\u0442\u043e \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0442\u0430\u0440\u0433\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0440\u0435\u043a\u043b\u0430\u043c\u044b. <\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u044e\u0434\u0438 \u0437\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u044e\u0442 \u044d\u0442\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0432\u043e \u0432\u0440\u0435\u0434 \u0434\u0440\u0443\u0433\u0438\u043c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044f <a href=\"https:\/\/www.securitylab.ru\/news\/522990.php\" rel=\"noopener noreferrer nofollow\">\u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f<\/a>.<\/p>\n<h3>\u0426\u0435\u043b\u044c:<\/h3>\n<p>\u041e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u043c\u043e\u0435\u0433\u043e email \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435\u043c.<\/p>\n<h3>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/h3>\n<p>\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0431\u0430\u043d\u043d\u0435\u0440 \u0438\u043b\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0432 email \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u044f \u0441\u043c\u043e\u0433\u0443 \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435.<\/p>\n<h3>\u0423\u0441\u043b\u043e\u0432\u0438\u0435:<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u043c\u043d\u043e\u0439 \u043f\u0438\u0441\u044c\u043c\u0430.<\/p>\n<h3>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/h3>\n<ul>\n<li>\n<p>\u041c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a <em>cookie \u0447\u0435\u0440\u0435\u0437 javascript \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 a.com<\/em>, \u043d\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043a  <em>b.com<\/em><\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#171;\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u044b\u00a0cookie&#187; \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435<\/p>\n<\/li>\n<\/ul>\n<h3>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b:<\/h3>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d5a\/721\/b6d\/d5a721b6d30db3c0118a6d35208e7b43.png\" alt=\"\" title=\"\" width=\"711\" height=\"522\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d5a\/721\/b6d\/d5a721b6d30db3c0118a6d35208e7b43.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 <strong>b.com<\/strong> \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 <strong>a.com<\/strong><\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f b.com:<\/h3>\n<p>\u0414\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e express.js &#8212; \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0438 \u043b\u0435\u0433\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u043e\u0438\u0445 \u043d\u0443\u0436\u0434.<\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ef7\/dbd\/f72\/ef7dbdf72e648a8b5d07d62ad7184135.png\" alt=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\" title=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\" width=\"296\" height=\"184\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ef7\/dbd\/f72\/ef7dbdf72e648a8b5d07d62ad7184135.png\"\/><figcaption>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440<code>bin\/www:<\/code><\/p>\n<pre><code class=\"javascript\">#!\/usr\/bin\/env node  \/**  * Module dependencies.  *\/  var app = require('..\/app'); var debug = require('debug')('tracked-pixel:server'); var http = require('http');  \/**  * Get port from environment and store in Express.  *\/  var port = normalizePort(process.env.PORT || '3000'); app.set('port', port);  \/**  * Create HTTP server.  *\/  var server = http.createServer(app);  \/**  * Listen on provided port, on all network interfaces.  *\/  server.listen(port); server.on('error', onError); server.on('listening', onListening);  \/**  * Normalize a port into a number, string, or false.  *\/  function normalizePort(val) {   var port = parseInt(val, 10);    if (isNaN(port)) {     \/\/ named pipe     return val;   }    if (port >= 0) {     \/\/ port number     return port;   }    return false; }  \/**  * Event listener for HTTP server \"error\" event.  *\/  function onError(error) {   if (error.syscall !== 'listen') {     throw error;   }    var bind = typeof port === 'string'     ? 'Pipe ' + port     : 'Port ' + port;    \/\/ handle specific listen errors with friendly messages   switch (error.code) {     case 'EACCES':       console.error(bind + ' requires elevated privileges');       process.exit(1);       break;     case 'EADDRINUSE':       console.error(bind + ' is already in use');       process.exit(1);       break;     default:       throw error;   } }  \/**  * Event listener for HTTP server \"listening\" event.  *\/  function onListening() {   var addr = server.address();   var bind = typeof addr === 'string'     ? 'pipe ' + addr     : 'port ' + addr.port;   debug('Listening on ' + bind); } <\/code><\/pre>\n<p> <code>app.js<\/code> \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a:<\/p>\n<pre><code class=\"javascript\">const express = require('express'); const cookieParser = require('cookie-parser'); const logger = require('morgan'); const indexRouter = require('.\/routes');  const app = express();  app.use(logger('dev')); app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(cookieParser());  app.use('\/', indexRouter);  module.exports = app;<\/code><\/pre>\n<p> <code>routes.js<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u044e &#171;\u043c\u0430\u0433\u0438\u044e&#187;.<br \/>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e base64 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f 1\u04451.<\/p>\n<pre><code class=\"javascript\">const express = require('express'); const router = express.Router();  const whitePixel = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';  \/\/\u043e\u0442\u0434\u0430\u044e \u043f\u0438\u043a\u0441\u0435\u043b\u044c const getPixelResponse = (res) => {   res.header('Access-Control-Allow-Origin', '*');   res.header('Content-type', 'image\/png');   res.end(Buffer.from(whitePixel, 'base64')); }  \/\/\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 TTL const getMaxAge = () => 60 * 60 * 24 * 1000 * 365;  \/\/\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0435\u0439 \u043a\u0443\u043a\u0438 const cookieName = 'myCookie';  \/\/\u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f router.get('\/auth', function(req, res, next) {   if (!req.cookies[cookieName]) {     res.cookie(cookieName, 'test', {        maxAge: getMaxAge(),        httpOnly: false,        domain: 'localhost',       secure: true,        sameSite: 'none'     });   }    getPixelResponse(res); });  \/\/\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u043a\u0443\u043a\u0443 router.get('\/test', function(req, res, next) {   console.log('Cookies', req.cookies)    getPixelResponse(res); });  module.exports = router;<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0432\u0441\u0435 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439, \u0431\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445<\/p>\n<pre><code class=\"json\">secure: true, sameSite: 'none'<\/code><\/pre>\n<p>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e:<\/p>\n<blockquote>\n<p>&#171;\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435&#187; (secure) cookie \u043e\u0442\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 SSL \u0438 HTTPS. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0430\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 cookies, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0430\u043c \u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u0435\u0441\u044c\u043c\u0430 \u0443\u044f\u0437\u0432\u0438\u043c \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u0430 \u0444\u043b\u0430\u0433\u00a0<code>secure<\/code>\u00a0\u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0437\u0430\u0449\u0438\u0442\u044b \u043d\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442.<\/p>\n<\/blockquote>\n<p>\u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 SSL, \u0445\u043e\u0442\u044f \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 <em>Chrome<\/em> \u044f \u0441\u043c\u043e\u0433 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043a \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443, \u043d\u043e \u0441 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435\u043c<\/p>\n<blockquote>\n<p>Mixed Content: The page at &#8216;https:\/\/example.com&#8217; was loaded over HTTPS, but requested an insecure element &#8216;<a href=\"http:\/\/localhost:3000\/auth'\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:3000\/auth&#8217;<\/a>. This request was automatically upgraded to HTTPS, For more information see <a href=\"https:\/\/blog.chromium.org\/2019\/10\/no-more-mixed-messages-about-https.htm\" rel=\"noopener noreferrer nofollow\">https:\/\/blog.chromium.org\/2019\/10\/no-more-mixed-messages-about-https.htm<\/a><\/p>\n<\/blockquote>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0444\u043b\u0430\u0433 <code>sameSite: 'none'. <\/code><\/p>\n<p>\u0418\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0432\u0438\u0434\u0438\u043c:<\/p>\n<blockquote>\n<p>\u0424\u0430\u0439\u043b\u044b cookie \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0441\u0435\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430\u0445, \u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u043e\u0442\u0432\u0435\u0442\u0430\u0445 \u043a\u0430\u043a \u043d\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b\u00a0<code>SameSite=None<\/code>, \u0442\u0430\u043a \u0438 \u043d\u0430\u00a0\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0415\u0441\u043b\u0438\u00a0\u043e\u043d \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d,\u00a0<code>Secure<\/code>\u00a0\u0430\u0442\u0440\u0438\u0431\u0443\u0442\u00a0cookie\u00a0\u00a0\u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d (\u0438\u043d\u0430\u0447\u0435 \u0444\u0430\u0439\u043b cookie \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d).<\/p>\n<\/blockquote>\n<p>\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e <em>sameSIte<\/em> \u0441\u043c\u043e\u0442\u0440\u0438\u043c <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Headers\/Set-Cookie\/SameSite\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<br \/>\u0421 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043b\u0438\u0435\u043d\u0442\u0443.<\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f a.com:<\/h3>\n<p>\u041d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<br \/>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043e\u0442\u0434\u0430\u0435\u043c \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0442\u043e \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 <em>HTML \u0438\u043b\u0438 Javascript.<\/em><\/p>\n<p>HTML \u0432\u0435\u0440\u0441\u0438\u044f:<\/p>\n<pre><code class=\"xml\">&lt;img src=\"http:\/\/localhost:3000\/auth\" alt=\"auth\"\/> &lt;img src=\"http:\/\/localhost:3000\/test\" alt=\"test\"\/><\/code><\/pre>\n<p>Javascript \u0432\u0435\u0440\u0441\u0438\u044f:<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u044f \u0438\u043c\u0435\u044e \u043f\u043e\u043b\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0442\u043e \u0434\u0435\u043b\u0430\u044e \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 <em>javascript<\/em>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u043d\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 <em>auth<\/em> \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 <em>cookie<\/em>) \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0442\u0435\u0441\u0442.<\/p>\n<pre><code class=\"javascript\">const preloadImage = function(url, callback) {     let img = new Image();     img.src = url;     img.onload = callback; }  preloadImage('http:\/\/localhost:3000\/auth', ()=>{     document.body.innerHTML += '&lt;img src=\"http:\/\/localhost:3000\/test\" alt=\"test\" \/>'; })<\/code><\/pre>\n<p>package.json<\/p>\n<pre><code class=\"json\">{   \"name\": \"pixel\",   \"author\": \"mldev\",   \"version\": \"0.1.0\",   \"private\": true,   \"scripts\": {     \"start\": \"node .\/bin\/www\"   },   \"dependencies\": {     \"cookie-parser\": \"~1.4.4\",     \"debug\": \"~2.6.9\",     \"express\": \"~4.17.1\",     \"morgan\": \"~1.9.1\"   } } <\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 <\/p>\n<p><code>npm start<\/code> <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0441\u0435 \u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443 \u0441 \u0441\u0430\u0439\u0442\u0430 <em>mail.google.com.<\/em><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0ad\/217\/660\/0ad21766090f4e556771f3074987ede2.png\" alt=\"\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c cookie\" title=\"\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c cookie\" width=\"1093\" height=\"957\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0ad\/217\/660\/0ad21766090f4e556771f3074987ede2.png\"\/><figcaption>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c cookie<\/figcaption><\/figure>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/eb6\/1ad\/5ea\/eb61ad5eaf31e39fa81b5e40daadd6b4.png\" alt=\"Cookie \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c\" title=\"Cookie \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c\" width=\"1096\" height=\"959\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/eb6\/1ad\/5ea\/eb61ad5eaf31e39fa81b5e40daadd6b4.png\"\/><figcaption>Cookie \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c<\/figcaption><\/figure>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>\u041c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044e <em>\u0441ookie<\/em>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u044c\u043c\u043e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e;<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430\u043b\u0438\u0447\u0438\u044f <em>cookie<\/em>, \u0447\u0442\u043e\u0431\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c &#171;\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439&#187; \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438;<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>production<\/em> \u043a\u043e\u0434\u043e\u043c.<\/p>\n<p><strong>\u041a\u043e\u0434 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 github<\/strong><br \/><a href=\"https:\/\/github.com\/MykhailoDev\/cookie-injection\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/MykhailoDev\/cookie-injection<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><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\/ru\/articles\/573046\/\"> https:\/\/habr.com\/ru\/articles\/573046\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044f Cookie, \u0433\u0434\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0438 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c<em>.<\/em> \u042d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u0430 \u0441 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0445\u0438\u0449\u0435\u043d\u0438\u044f \u0447\u0443\u0436\u0438\u0445 \u043a\u0443\u043a\u0438, \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0441\u0432\u043e\u0438\u0445 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f.<\/p>\n<h2>\u0414\u043b\u044f \u0447\u0435\u0433\u043e \u043d\u0443\u0436\u043d\u0430 \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044f Cookie?<\/h2>\n<p>\u041a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u0430\u044f \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Cookie \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043e\u0442 <strong><em>a.com<\/em><\/strong> \u0434\u043e <strong><em>b.com<\/em><\/strong><\/p>\n<h3>\u0413\u0434\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c?<\/h3>\n<p>\u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0434\u0430\u0442\u044c \u043d\u0430\u0448\u0438\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043e\u043d\u0438 \u0441\u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0443 \u0441\u0435\u0431\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0431\u0430\u043d\u043d\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0433\u0435\u043e\u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u043b\u044e\u0431\u0430\u044f \u0434\u0440\u0443\u0433\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0433\u0434\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u043c\u0438. \u0422\u0430\u043a\u0436\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 &#171;\u0432\u0435\u0441\u0442\u0438&#187; \u0435\u0433\u043e \u043e\u0442 \u0441\u0430\u0439\u0442\u0430 \u043a \u0441\u0430\u0439\u0442\u0443, \u0447\u0442\u043e \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0442\u0430\u0440\u0433\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0440\u0435\u043a\u043b\u0430\u043c\u044b. <\/p>\n<p>\u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043b\u044e\u0434\u0438 \u0437\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u044e\u0442 \u044d\u0442\u0438\u043c\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0432\u043e \u0432\u0440\u0435\u0434 \u0434\u0440\u0443\u0433\u0438\u043c \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044f <a href=\"https:\/\/www.securitylab.ru\/news\/522990.php\" rel=\"noopener noreferrer nofollow\">\u043f\u0438\u043a\u0441\u0435\u043b\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f<\/a>.<\/p>\n<h3>\u0426\u0435\u043b\u044c:<\/h3>\n<p>\u041e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u043c\u043e\u0435\u0433\u043e email \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u0435\u043b\u0435\u043c.<\/p>\n<h3>\u0420\u0435\u0448\u0435\u043d\u0438\u0435:<\/h3>\n<p>\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0431\u0430\u043d\u043d\u0435\u0440 \u0438\u043b\u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044c \u0432 email \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u044f \u0441\u043c\u043e\u0433\u0443 \u043e\u0442\u0441\u043b\u0435\u0434\u0438\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435.<\/p>\n<h3>\u0423\u0441\u043b\u043e\u0432\u0438\u0435:<\/h3>\n<p>\u041d\u0443\u0436\u043d\u043e \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u043c\u043d\u043e\u0439 \u043f\u0438\u0441\u044c\u043c\u0430.<\/p>\n<h3>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f:<\/h3>\n<ul>\n<li>\n<p>\u041c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a <em>cookie \u0447\u0435\u0440\u0435\u0437 javascript \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 a.com<\/em>, \u043d\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u043a  <em>b.com<\/em><\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0438 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#171;\u0411\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u044b\u00a0cookie&#187; \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435<\/p>\n<\/li>\n<\/ul>\n<h3>\u0421\u0445\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u044b:<\/h3>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 <strong>b.com<\/strong> \u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0432 \u0432\u0438\u0434\u0435 <strong>a.com<\/strong><\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f b.com:<\/h3>\n<p>\u0414\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e express.js &#8212; \u0431\u044b\u0441\u0442\u0440\u043e\u0435 \u0438 \u043b\u0435\u0433\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043c\u043e\u0438\u0445 \u043d\u0443\u0436\u0434.<\/p>\n<p>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<figure class=\"\"><figcaption>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/figcaption><\/figure>\n<p>\u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440<code>bin\/www:<\/code><\/p>\n<pre><code class=\"javascript\">#!\/usr\/bin\/env node  \/**  * Module dependencies.  *\/  var app = require('..\/app'); var debug = require('debug')('tracked-pixel:server'); var http = require('http');  \/**  * Get port from environment and store in Express.  *\/  var port = normalizePort(process.env.PORT || '3000'); app.set('port', port);  \/**  * Create HTTP server.  *\/  var server = http.createServer(app);  \/**  * Listen on provided port, on all network interfaces.  *\/  server.listen(port); server.on('error', onError); server.on('listening', onListening);  \/**  * Normalize a port into a number, string, or false.  *\/  function normalizePort(val) {   var port = parseInt(val, 10);    if (isNaN(port)) {     \/\/ named pipe     return val;   }    if (port >= 0) {     \/\/ port number     return port;   }    return false; }  \/**  * Event listener for HTTP server \"error\" event.  *\/  function onError(error) {   if (error.syscall !== 'listen') {     throw error;   }    var bind = typeof port === 'string'     ? 'Pipe ' + port     : 'Port ' + port;    \/\/ handle specific listen errors with friendly messages   switch (error.code) {     case 'EACCES':       console.error(bind + ' requires elevated privileges');       process.exit(1);       break;     case 'EADDRINUSE':       console.error(bind + ' is already in use');       process.exit(1);       break;     default:       throw error;   } }  \/**  * Event listener for HTTP server \"listening\" event.  *\/  function onListening() {   var addr = server.address();   var bind = typeof addr === 'string'     ? 'pipe ' + addr     : 'port ' + addr.port;   debug('Listening on ' + bind); } <\/code><\/pre>\n<p> <code>app.js<\/code> \u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a:<\/p>\n<pre><code class=\"javascript\">const express = require('express'); const cookieParser = require('cookie-parser'); const logger = require('morgan'); const indexRouter = require('.\/routes');  const app = express();  app.use(logger('dev')); app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(cookieParser());  app.use('\/', indexRouter);  module.exports = app;<\/code><\/pre>\n<p> <code>routes.js<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0432\u0441\u044e &#171;\u043c\u0430\u0433\u0438\u044e&#187;.<br \/>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e base64 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0433\u043e \u043f\u0438\u043a\u0441\u0435\u043b\u044f 1\u04451.<\/p>\n<pre><code class=\"javascript\">const express = require('express'); const router = express.Router();  const whitePixel = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';  \/\/\u043e\u0442\u0434\u0430\u044e \u043f\u0438\u043a\u0441\u0435\u043b\u044c const getPixelResponse = (res) => {   res.header('Access-Control-Allow-Origin', '*');   res.header('Content-type', 'image\/png');   res.end(Buffer.from(whitePixel, 'base64')); }  \/\/\u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 TTL const getMaxAge = () => 60 * 60 * 24 * 1000 * 365;  \/\/\u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u043e\u0435\u0439 \u043a\u0443\u043a\u0438 const cookieName = 'myCookie';  \/\/\u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f router.get('\/auth', function(req, res, next) {   if (!req.cookies[cookieName]) {     res.cookie(cookieName, 'test', {        maxAge: getMaxAge(),        httpOnly: false,        domain: 'localhost',       secure: true,        sameSite: 'none'     });   }    getPixelResponse(res); });  \/\/\u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0447\u0442\u043e \u043c\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0430\u0448\u0443 \u043a\u0443\u043a\u0443 router.get('\/test', function(req, res, next) {   console.log('Cookies', req.cookies)    getPixelResponse(res); });  module.exports = router;<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0432\u0441\u0435 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u041e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u0435\u0439, \u0431\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0430\u0445<\/p>\n<pre><code class=\"json\">secure: true, sameSite: 'none'<\/code><\/pre>\n<p>\u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e:<\/p>\n<blockquote>\n<p>&#171;\u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435&#187; (secure) cookie \u043e\u0442\u0441\u044b\u043b\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 SSL \u0438 HTTPS. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0430\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043b\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 cookies, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0430\u043c \u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0432\u0435\u0441\u044c\u043c\u0430 \u0443\u044f\u0437\u0432\u0438\u043c \u0432 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438, \u0430 \u0444\u043b\u0430\u0433\u00a0<code>secure<\/code>\u00a0\u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0437\u0430\u0449\u0438\u0442\u044b \u043d\u0435 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442.<\/p>\n<\/blockquote>\n<p>\u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 SSL, \u0445\u043e\u0442\u044f \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0435 \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 <em>Chrome<\/em> \u044f \u0441\u043c\u043e\u0433 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043a \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443, \u043d\u043e \u0441 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435\u043c<\/p>\n<blockquote>\n<p>Mixed Content: The page at &#8216;https:\/\/example.com&#8217; was loaded over HTTPS, but requested an insecure element &#8216;<a href=\"http:\/\/localhost:3000\/auth'\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:3000\/auth&#8217;<\/a>. This request was automatically upgraded to HTTPS, For more information see <a href=\"https:\/\/blog.chromium.org\/2019\/10\/no-more-mixed-messages-about-https.htm\" rel=\"noopener noreferrer nofollow\">https:\/\/blog.chromium.org\/2019\/10\/no-more-mixed-messages-about-https.htm<\/a><\/p>\n<\/blockquote>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u044b \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0444\u043b\u0430\u0433 <code>sameSite: 'none'. <\/code><\/p>\n<p>\u0418\u0437 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0432\u0438\u0434\u0438\u043c:<\/p>\n<blockquote>\n<p>\u0424\u0430\u0439\u043b\u044b cookie \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u043e \u0432\u0441\u0435\u0445 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430\u0445, \u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u043e\u0442\u0432\u0435\u0442\u0430\u0445 \u043a\u0430\u043a \u043d\u0430 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b\u00a0<code>SameSite=None<\/code>, \u0442\u0430\u043a \u0438 \u043d\u0430\u00a0\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0415\u0441\u043b\u0438\u00a0\u043e\u043d \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d,\u00a0<code>Secure<\/code>\u00a0\u0430\u0442\u0440\u0438\u0431\u0443\u0442\u00a0cookie\u00a0\u00a0\u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d (\u0438\u043d\u0430\u0447\u0435 \u0444\u0430\u0439\u043b cookie \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d).<\/p>\n<\/blockquote>\n<p>\u041f\u043e\u043b\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043f\u043e <em>sameSIte<\/em> \u0441\u043c\u043e\u0442\u0440\u0438\u043c <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Headers\/Set-Cookie\/SameSite\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<br \/>\u0421 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u043c\u044b \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438, \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043a\u043b\u0438\u0435\u043d\u0442\u0443.<\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f a.com:<\/h3>\n<p>\u041d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<br \/>\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043e\u0442\u0434\u0430\u0435\u043c \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0442\u043e \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 <em>HTML \u0438\u043b\u0438 Javascript.<\/em><\/p>\n<p>HTML \u0432\u0435\u0440\u0441\u0438\u044f:<\/p>\n<pre><code class=\"xml\">&lt;img src=\"http:\/\/localhost:3000\/auth\" alt=\"auth\"\/> &lt;img src=\"http:\/\/localhost:3000\/test\" alt=\"test\"\/><\/code><\/pre>\n<p>Javascript \u0432\u0435\u0440\u0441\u0438\u044f:<\/p>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u044f \u0438\u043c\u0435\u044e \u043f\u043e\u043b\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u0438, \u0442\u043e \u0434\u0435\u043b\u0430\u044e \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 <em>javascript<\/em>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043c\u043d\u0435 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 <em>auth<\/em> \u0437\u0430\u043f\u0440\u043e\u0441\u0430 (\u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 <em>cookie<\/em>) \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0442\u0435\u0441\u0442.<\/p>\n<pre><code class=\"javascript\">const preloadImage = function(url, callback) {     let img = new Image();     img.src = url;     img.onload = callback; }  preloadImage('http:\/\/localhost:3000\/auth', ()=>{     document.body.innerHTML += '&lt;img src=\"http:\/\/localhost:3000\/test\" alt=\"test\" \/>'; })<\/code><\/pre>\n<p>package.json<\/p>\n<pre><code class=\"json\">{   \"name\": \"pixel\",   \"author\": \"mldev\",   \"version\": \"0.1.0\",   \"private\": true,   \"scripts\": {     \"start\": \"node .\/bin\/www\"   },   \"dependencies\": {     \"cookie-parser\": \"~1.4.4\",     \"debug\": \"~2.6.9\",     \"express\": \"~4.17.1\",     \"morgan\": \"~1.9.1\"   } } <\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440 <\/p>\n<p><code>npm start<\/code> <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0441\u0435 \u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u0443\u0434\u0443 \u0441 \u0441\u0430\u0439\u0442\u0430 <em>mail.google.com.<\/em><\/p>\n<figure class=\"full-width\"><figcaption>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c cookie<\/figcaption><\/figure>\n<figure class=\"full-width\"><figcaption>Cookie \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c<\/figcaption><\/figure>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>\u041c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u043e\u0441\u0441-\u0434\u043e\u043c\u0435\u043d\u043d\u0443\u044e \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u044e <em>\u0441ookie<\/em>, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u044c\u043c\u043e \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e;<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430\u043b\u0438\u0447\u0438\u044f <em>cookie<\/em>, \u0447\u0442\u043e\u0431\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c &#171;\u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439&#187; \u0437\u0430\u043f\u0440\u043e\u0441 \u0438 \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438;<\/p>\n<\/li>\n<\/ul>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <em>production<\/em> \u043a\u043e\u0434\u043e\u043c.<\/p>\n<p><strong>\u041a\u043e\u0434 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u0430 github<\/strong><br \/><a href=\"https:\/\/github.com\/MykhailoDev\/cookie-injection\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/MykhailoDev\/cookie-injection<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><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\/ru\/articles\/573046\/\"> https:\/\/habr.com\/ru\/articles\/573046\/<\/a><br \/><\/br><\/br><\/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-397529","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/397529","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=397529"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/397529\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=397529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=397529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=397529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}