-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractical_10.html
More file actions
30 lines (27 loc) · 959 Bytes
/
Copy pathpractical_10.html
File metadata and controls
30 lines (27 loc) · 959 Bytes
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
#Madanraj Sagar
<!DOCTYPE html>
<html>
<head>
<title>Cookie Demo</title>
</head>
<body>
<button onclick="createSessionCookie()">Create Session Cookie</button>
<button onclick="createPersistentCookie()">Create Persistent Cookie</button>
<button onclick="readCookies()">Read Cookies</button>
<p id="cookieInfo"></p>
<script>
function createSessionCookie() {
document.cookie = "sessionCookie=value; expires=Thu, 01 Jan 1970 00:00:00 UTC";
document.getElementById("cookieInfo").innerHTML = "Session cookie created.";
}
function createPersistentCookie() {
document.cookie = "persistentCookie=value; expires=Thu, 01 Jan 2025 00:00:00 UTC";
document.getElementById("cookieInfo").innerHTML = "Persistent cookie created.";
}
function readCookies() {
let allCookies = document.cookie;
document.getElementById("cookieInfo").innerHTML = "All cookies: " + allCookies;
}
</script>
</body>
</html>