For example, the cookie that is used to store a username can be written as follows:
* username is the name and John is the value of the cookie.
To create the above cookie, you need to assign the cookie to the window.document.cookie object. The browser will automatically store the cookie in the memory when it comes across the above statement.
Each cookie should consists of four parts: name, assignment operator, value and semicolon. The assignment statement that creates the cookie is shown below:
Enter your name:
<input type=”text” name=”User”>
<input type=”button” value=”Enter” name=”Enter” onClick=”CreateCookie()”>
Enter Student Name:<input type=”text” name=”student” >
<input type=”button” value=”Enter” name=”Enter” onClick=”WriteCookie()”><br><br>
The cookie is:<input type=”text” name=”showcookie” >
<input type=”button” value=”Show Cookie” name=”Display” onClick=”ReadCookie()”>
View the output
* The Script works best in IE
*Note that the unescape() function is used to decode an encoded string. For example,