Tracking cookies allows a website owner to obtain information about the users who visit their site. The site owner can use the information to learn more about visitors or provide them with a more personalized and optimized experience. For example, a cookie can save the username and password so that a visitor does not have to fill in that information each time they enter the site and thus save time.
Steps

Step 1. Define what information you want the cookie to store
Before creating a tracking cookie, you must determine what type of information you want to track about your site visitors. For example, you may find it important to know the zip code of a person visiting your site if your site sells products that require shipping costs and certain sales taxes.

Step 2. Use HTML
If you created your site using HTML code and are somewhat familiar with programming, you can create a tracking cookie from scratch.
- Use the "Response" command to create a cookie on a visitor's computer. "Response. Cookies (" CookieName ") = value" is the most basic form of this type of code. The code: “Response. Cookies (" VisitorName ") = Request. Form (" UserName ")” would allow you to track the name of a visitor.
- Use the "Request" command to get the cookie. “Request. Cookies (" CookieName ")” would allow you to get the information from the visitor's computer when they return to the website.

Step 3. However, note that the HTML standard has no commands
"Response" and "Request" are part of Microsoft's ASP (Active Server Pages). If your website does not support ASP, you will need to investigate other methods of generating cookies, such as CGI or PHP scripts.

Step 4. Consider cookie-tracking software as an alternative to writing your own code
There is software that will do the heavy lifting of creating code for you.
This software will allow you to create certain types of cookies; sometimes a single type of software will only allow you to create a specific cookie. Some of these programs are considered "freeware," and therefore will cost you nothing. Tracking cookie software can help you restrict how many times a visitor can download software from your website by remembering that the software was previously downloaded

Step 5. Add security to your cookie
Internet security is a key concern of most Internet users. It is important to provide security in such a way that visitor information is protected.
- A domain property will restrict the cookie so that it cannot be read by another website. A code example for this is: Response. Cookies ("CookieName"). Domain = "www.mydomain.com"
- A path property will restrict the cookie from being read by a specific path. A code example for this is: Response. Cookies ("CookieName"). Path = "/ maindir / subdir / path"

Step 6. Give your cookie an expiration date
A cookie will expire once the web browser the visitor uses to view your site is closed. An expiration date must be established if you want to store the cookie so that when the user returns the information is saved. An example of this code is: Response. Cookies ("CookieName"). Expires = # January01, 2010 # (Assuming January 1, 2010 as the expiration date).