Итак, самая простая страница:
<html>
<head>
<title>Page title</title>
</head>
<body>
<p>Текст</p>
<button>Click Me</button>
</body>
</html>
CodeBase | Frontend
Please open Telegram to view this post
VIEW IN TELEGRAM
CodeBase | Frontend
Please open Telegram to view this post
VIEW IN TELEGRAM
Пример:
document.cookie = "username=John Doe; expires=Thu, 18 Dec 2023 12:00:00 UTC; path=/";
Пример:
sessionStorage.setItem('username', 'John');
console.log(sessionStorage.getItem('username')); // вывод "John"
Пример:
localStorage.setItem('username', 'John');
console.log(localStorage.getItem('username')); // вывод "John"
CodeBase | Frontend
Please open Telegram to view this post
VIEW IN TELEGRAM
При работе с cookies в JavaScript можно настроить различные атрибуты, которые определяют их поведение.
Эти атрибуты добавляются в строку cookie в виде пар ключ-значение.
Имя и значение определяют данные, которые будут храниться в cookie. Формат выглядит как name=value.
Например, document.cookie = "username=johndoe".
Атрибут expires определяет срок действия cookie. По умолчанию cookie хранятся до закрытия браузера. Чтобы установить конкретную дату истечения срока действия, используйте expires=date.
Например, document.cookie = "username=johndoe; expires=Thu, 31 Dec 2022 23:59:59 GMT".
Атрибут domain указывает на домен, к которому принадлежит cookie. По умолчанию cookie связаны с текущим доменом. Для явного указания домена используйте атрибут domain.
Например, document.cookie = "username=johndoe; domain=example.com".
Атрибут path определяет путь в домене, по которому доступен cookie. По умолчанию cookie доступен для всего домена. Чтобы ограничить cookie определенным путем, укажите атрибут path.
Например, document.cookie = "username=johndoe; path=/admin".
Атрибут secure гарантирует, что cookie передается только через безопасное HTTPS-соединение. Для защиты cookie включите атрибут secure.
Например, document.cookie = "username=johndoe; secure".
CodeBase | Frontend | #js
Please open Telegram to view this post
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
CodeBase | Frontend | #js #framework
Please open Telegram to view this post
VIEW IN TELEGRAM
Поможет прокачать вам свои навыки!
CodeBase | Frontend | #макет
Please open Telegram to view this post
VIEW IN TELEGRAM
CodeBase | Frontend | #webpack
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
CodeBase | Frontend | #обучение #sass
Please open Telegram to view this post
VIEW IN TELEGRAM
CodeBase | Frontend | #макет
Please open Telegram to view this post
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
CodeBase | Frontend | #html #css
Please open Telegram to view this post
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
CodeBase | Frontend | #scss_js
Please open Telegram to view this post
VIEW IN TELEGRAM
This media is not supported in your browser
VIEW IN TELEGRAM
CodeBase | Frontend | #plugins
Please open Telegram to view this post
VIEW IN TELEGRAM