| Acknowledgement Much of the work on cookies has been done by Bill Dortch, hIdaho Design bdortch@hidaho.com and this section is highly influenced by his work. |
You can make a cookie by entering a name in the text box and pressing the 'Set Name' button. If you then press the 'Show cookie' button, you will see the contents of your cookie.
When you press set name, it calls a function called setcookie. This function uses the following code:
function setcookie(){
document.cookie = 'Cookie Name='+document.form1.cookieName.value;
}
We make the cookie (which is a string) contain the information 'Cookie Name=' plus the name we enter in the text box.
function showCookie(){
alert(document.cookie);
}
when we click the button, Show cookie, we get the contents of the cookie in the alert. I entered 'Ken' in the box, so the alert says: 'Cookie Name=Ken'.
So we have a cookie with some information. However, when we close the browser, and restart it our cookie has gone! Not much so far, but a start. The next step with cookies is to make them last a little longer.
The jsEditor contains a cookie wizard to put the basic code into your page. You can modify this code to create the effects you want. In addition to its many other features, you can use the jsEditor's knowledge base to explore the Math object. You can order the jsEditor online and download the full version immediately, so in a few minutes you could be using it to help you learn and develop scripts.
Next: The next step
And for some programming for your brain: check out New Life Course