Javascript cookie string

We can set a cookie by setting document.cookie to a cookie string.
 The following code will set a cookie with the UserName set as Paul,
 and an expiration date of 28 December 2010.

<html>
<head>
<script language=JavaScript>
   document.cookie = "UserName=Paul;expires=Tue, 28 Dec 2010 00:00:00;";
</script>
</head>
<body>
<p>This page just created a cookie</p>
</body>
</html>

Save the page as FreshBakedCookie.htm. We'll see how the code works as we
 discuss the parts of a cookie string, but first let's see what happens
 when a cookie is created.

In this section we'll see how to look at the cookies that are already stored by IE on our computer. We'll then load the cookie-creating page we just created with the preceding code to see what effect this has.

First we need to open IE. I'm using IE 6, so if you're using IE 4 or 5 you will find the screenshots and menus in slightly different places.

Before we view the cookies, we'll first clear the temporary Internet file folder for the browser because this will make it easier to view the cookies that our browser has stored. In IE, select Internet Options from the Tools menu,