File size: 1,340 Bytes
315f0c3 128cba5 315f0c3 128cba5 315f0c3 128cba5 315f0c3 128cba5 315f0c3 128cba5 315f0c3 128cba5 315f0c3 128cba5 315f0c3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>Admin Access Cookie 切り替え</title>
<style>
body {
font-family: sans-serif;
padding: 2rem;
}
button {
margin: 0.5rem;
padding: 0.5rem 1rem;
}
#status {
margin-top: 1rem;
font-weight: bold;
}
</style>
</head>
<body>
<h1>Admin Access Cookie 切り替え</h1>
<button onclick="setAdminAccess()">admin_access=true を設定</button>
<button onclick="removeAdminAccess()">admin_access を削除</button>
<div id="status"></div>
<script>
function setAdminAccess() {
// Cookie を設定(有効期限は1日)
document.cookie = "admin_access=true; path=/; max-age=86400";
updateStatus();
}
function removeAdminAccess() {
// Cookie を削除(有効期限を過去にする)
document.cookie = "admin_access=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;";
updateStatus();
}
function updateStatus() {
const status = document.cookie.includes("admin_access=true");
document.getElementById("status").textContent =
`document.cookie.includes("admin_access=true") の結果: ${status}`;
}
// ページ読み込み時にステータスを表示
window.onload = updateStatus;
</script>
</body>
</html>
|