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 consist of four parts: name, assignment operator, value and semicolon. The assignment statement that creates the cookie is shown below:
View the output
* The Script works best in IE
*Note that the unescape() function is used to decode an encoded string. For example,