Page 170 - Computer Software Application TP - Volume 1
P. 170
COMPUTER SOFTWARE APPLICATION - CITS
EXERCISE 43 : Creating Cookies with JavaScript
Objectives
At the end of this exercise you shall be able to
• create cookies using javascript
• display cookie details using javascript
• delete a cookie using javascript.
Requirements
Tools/Materials
• Desktop / Laptop with latest configuration
• Text editor
• Web browser
Procedure
TASK 1: Create a cookie and display its value using an alert
1 Open the text editor
2 Write the following codes
<html>
<head>
<title> Cookies </title>
</head>
<body>
<script>
document.cookie=”username=sun”;
document.cookie=”age=33”;
document.cookie=”country=india”;
alert(document.cookie);
</script>
</body>
</html>
3 Save the program as a .html file
4 Open the html file with a web browser and verify the output.
155
CITS : IT & ITES - Computer Software Application - Exercise 42