Write A Program To Create A Session Cookie and Display Content of Cookie
Write A Program To Create A Session Cookie and Display Content of Cookie
<html>
<script lang="Javascript" type="text/javascript">
function Cookie()
{ var cookie_val = name.value;
document.cookie = "<b>Username = </b>"+ cookie_val;
alert("Cookie created");
}
</script>
<body>
Enter your Name : <input type="text" id="name"/><br>
<input type="button" value="Create Cookie"
onclick="Cookie()"/>
</body>
</html>
Practica 9
<html>
<script>
function persistent_cookie()
{ var now = new Date();
now.setMonth(now.getMonth()+ 1);
var cookie_val = user.value;
document.cookie = "Username = "+cookie_val
+"Expires = "+ now.toUTCString();
alert("Expiry Date of Cookie : "+
now.toUTCString());
}
</script>
<body>
Enter Name : <input type="text" id="user"/> <br>
<input type="button" value="Cookie"
onclick="persistent_cookie()"/>
</body>
</html>