In the header part of the HTML document that uses cookies include the following:
<script src="http://condor.depaul.edu/~mschaefe/cookies.js">
</script>
(Textversion of the code, in case you want to modify it.)
You will then have two functions you can use for cookies.
Note: cookies are visible on the page on which they are set, pages in the same directory, or subdirectories of that directory. For example if a cookie is set on the page public_html/test/cookietest.html then a page in the directory public_html/ cannot see that cookie, but any web-page in public_html/test/ could.
For more advanced information see the Netscape Javascript Guide.