0% found this document useful (0 votes)
4 views

CSS Practical 10

Uploaded by

mpvrsmshriram807
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

CSS Practical 10

Uploaded by

mpvrsmshriram807
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Practical No.

10
Develop a webpage for creating session and persistent cookies.
Observe the effects with browser cookie settings.
<html>
<head>
<title>Cookie</title>
</head>
<body>
<div style="text-align: center;">
Enter Your Email : <input type="email" name="" id="Email"
size="25" style="margin-bottom: 4px; margin-left : 20px;"><br>
Enter Your Password : <input type="password" name=""
id="Password" size="25" style="margin-bottom: 10px;"><br>
<input type="button" name="b1" value="Create"
onclick="createCookie()">
<input type="button" name="b2" value="Display"
onclick="ReadCookie()">
<input type="button" name="b3" value="Write Cookie"
onclick="writecookie()">
<input type="button" name="b3" value="Delete"
onclick="deleteCookie()">
<input type="button" name="b4" value="Expire"
onclick="expireCookie()">
</div>
</body>
<script type="text/JavaScript">
function createCookie()
{
alert("Cookie is Created ");
document.cookie = "Email = "+
document.getElementById("Email").value;
document.cookie = "Password = "+
document.getElementById("Password").value;
}
function ReadCookie()
{
if(!((document.cookie != "")))
alert("There's no cookies to display");
alert(document.cookie)
}
function deleteCookie()
{
document.cookie = "Email = "+
document.getElementById("Email").value +";expires=Mon, 06 Nov
2022 12:00:00 UTC";
document.cookie = "Password = "+
document.getElementById("Password").value+";expires=Mon, 06
Nov 2022 12:00:00 UTC";
var Cdata = document.cookie; if(Cdata == "")
alert("Cookies are Deleted"); else
alert("Cookies are not Deleted Yet ..")
}
function expireCookie()
{
document.cookie = "Email = "+
document.getElementById("Email").value +";expires=Mon, 06 Nov
2022 12:00:00 UTC";
document.cookie = "Password = "+
document.getElementById("Password").value+";expires=Mon, 06
Nov 2022 12:00:00 UTC";
alert("Cookie has been Expired !!");
}
function writecookie()
{
document.cookie = "Email = "+
document.getElementById("Email").value;
document.cookie = "Password = "+
document.getElementById("Password").value;
alert("Cookie Written Succesfully !!!");
}
</script>
</html>
 Creating cookie

 Cookie created

 Display cookie

 Write cookie

 Delete cookie
 Trying to display cookie after deletion

Expire date

You might also like