How to Use HTML Cookies
A webmaster who wants to track clients or retrieve information uses cookies. CGI and Javascript are used to set cookies using HTML DOM. It is a method for retrieving and using information; an example is filling out a form. The script embeds the cookie into the HTML.
Instructions
-
-
1
Choose CGI or Java script. If you choose Java script, you'll write the cookie script, write the script to read it and put a code in your HTML body to link with the code, which is called setting. The code writer sets the cookie. The way to write CGI code for cookies is similar.
-
2
Write the Java script. Go to a site that that lets you use their code or learn how to write the code. Write Java script cookies, which include a string value and return. Use the values for domain and path. Assign the cookie to the object. To make a cookie with a certain expiration date, use the string function. This converts it to the right string and involves the Java script Date Object code.
-
-
3
Write the code for retrieving the string using code for the name, value and path of the cookie. The code will be taken from document.cookie. This is called reading the code. The reading involves the parsing of name-value pairs. The web master's cookie is called when a visitor clicks on a link.
-
4
Use Java script code to retrieve the user's information like his user name and the answer to the question the user chooses to retrieve a lost password. The way he does this is by using a cookie string.
-
1