-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcookie.html
More file actions
32 lines (29 loc) · 1013 Bytes
/
cookie.html
File metadata and controls
32 lines (29 loc) · 1013 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
31
32
<html>
<body onload="getCookie()">
<form name>
<label> Username: </label>
<input type="text" id="username" /><br><br>
<label> Password: </label>
<input type="password" id="password" /><br><br>
<input type="button" value="Register" onclick="setCookie()" />
<p id="content"></p>
</body>
<script>
function setCookie() {
if(document.getElementById("username").value ==="" && document.getElementById("password").value ==="") {
alert(" please dont keep blank ")
}
else
document.cookie =
"password = " + document.getElementById("password").value + ";";
getCookie();
}
function getCookie() {
var cookiearray = document.cookie.split("=");
if (cookiearray[0] == "password")
document.getElementById("content").innerHTML = "Last used password: " + cookiearray[1];
else
document.getElementById("content").innerHTML = "Cookie not found"
}
</script>
</html>