pdfgen/Core/js/getcookies.js
2025-08-16 07:28:01 +00:00

21 lines
685 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// GET COOKIES
module.exports = function(req) {
const cookieHeader = req.headers.cookie;
if (cookieHeader) {
// Разбиваем строку Cookie на массив кук, разделенных "; "
const cookieArray = cookieHeader.split('; ');
// Создаем объект, чтобы хранить куки
const cookies = {};
// Парсим каждую куку и добавляем ее в объект cookies
cookieArray.forEach(cookie => {
const [name, value] = cookie.split('=');
cookies[name] = value;
});
return cookies;
} else return false;
}