JavaScript でクッキーを作成


simple_cookie.html
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8" />
<title>Cookie</title>
<script type="text/javascript">
document.cookie = "aa='バナナ';SameSite=strict";
document.cookie = "bb='りんご';SameSite=strict";
document.cookie = "cc='みかん';SameSite=strict";
document.cookie = "message='こんにちは';SameSite=strict";
console.log(document.cookie);
</script>
</head>
<body>
<h2>Cookie</h2>
<hr />
Apr/27/2021<br />
</body>
</html>

実行結果