Cookies are harmless little bits of information left on your computer by a Web page. Those little bits of information may be used to simplify or personalize your next visit to that page or Web site. Unfortunately, these bits of information can be used as tracking cookies. So how harmless are they really?

First of all, be assured that cookies are not viruses, cannot damage your computer, and cannot replicate themselves. Nor can they crawl around your computer seeking out personal information stored on your hard drive. They are simply little bits of text.

How do Cookies Work?

A cookie can only store information that you made available by visiting a Web page: the contents of the page, the URL of the page you whose link you clicked to get there (the referrer page), and the time you got there. If there are input fields on the page, you also make available whatever you enter in those fields. It is up to the person who coded the Web page to determine what information, if any, is put into a cookie. Most Web page programmers have no reason to save any information from a page, so most pages do not create cookies.

The good news is that cookies may only be accessed by pages from the same domain as the page that created the cookie. For example, cookies created by pages in my website can only be accessed by other pages in the website.

Most of the pages of my site do not save cookies. However, I do have more than one page with fields for entering an e-mail address. To make your visit a little easier, I save the entered e-mail address in a cookie. Then, once you enter the e-mail address on one page, that same e-mail address is automatically filled in for you on other pages.

The programmer of the page chooses how long a cookie will exist. On all my pages, I have the cookies expire when the session ends (as soon as all the browser windows are closed). Once expired, the cookies are deleted.

Some Web page programmers may choose to make a cookie last longer. For example, a longer lasting cookie is required to program a Web page to display different information to a first-time visitor than to a return visitor. Every time the page is loaded, the page should check if the cookie exists. If not, the page should create the cookie. If the cookie exists, the page should present the information tailored to return visitors. The programmer may make such a cookie last days, months, years, or never expire.

Another great use of cookies is to record who logged in last. For example, a saved cookie informs who was last logged in. That is why you do not need to log in to every time you want to shop at Amazon, and Amazon is able to display your name on its page. But that is also why you need to log in again if you go to from a different computer or from a different browser. The cookie only identifies the last person who logged in on that computer using that browser. All shopping cart, credit card, and other account information is kept on Amazon’s server, not in cookies. Therefore, if you log in to Amazon on another computer, you can access the same shopping cart and account information you were using on a different computer.

So How Do Tracking Cookies Work?

A Web page can create a unique cookie for you on your computer. This unique cookie is just a little bit of text, but it can be used to identify all visits made by you. The Web page can then save the unique value it gave you, and URL of the referrer page, to its server every time you visit the page. In this way, it can build a list of the places you’ve visited before coming to its page. In other words, it can build a profile of the kinds of pages you like to visit.

But is that a problem if you only visit pages you know and trust? Do you care if a trustworthy site can track what sites you like to visit? Maybe, maybe not. After all, it can only collect information when you visit pages within its own site, right?

The site limitation is sidestepped by use of third-party cookies. Third-party cookies usually come from ads that are placed on Web pages. These ads, and their programmed code, come from a different domain than the page itself. For example, if a page on has an ad from domain, can create and access cookies on your computer whenever you visit page Now if has its ads on many pages from many domains, such as,, and more, and if you visit many of those pages, can start to collect information about your web browsing habits from all those pages. can then target the kinds of ads it displays for you based on what sites you like to visit and which ads you clicked on.

How do these third-party tracking cookies end up on so many sites? These usually come from free programs that people can add to their Web page, or come with free Web hosting services, or come with ads you are being paid to include on your Web page. If you are creating your own Web pages and see some great free code to add to your page, check it out before you add it. It might have some unwanted cookies that come with it.

Should You Block or Delete Cookies?

Over time many, many cookies will be created on your computer. You could use your browser tools and settings to block cookies or to delete cookies. However, if you block or delete all cookies, you will lose out on the many conveniences for which cookies were created. Some sites may not work at all without the use of cookies. Some sites depend on knowing what you entered on one page before they can appropriately display the next page.

I once took the option to delete all cookies on my computer. I was surprised at how many pages required me to reenter information that had been defaulting to saved cookie values. It was weeks before I had all my favorite sites working well again.

Most browsers also have a setting to block just third-party cookies. Blocking third-party cookies should at least block the worst of the tracking cookies. However, there may be legitimate uses of third-party cookies, such as third-party stat counters.

If nothing else, you should at least consider running a good anti-spyware program. Such programs are typically configured to search for and remove known tracking cookies.


Create cookies on your Web pages if it will create a better experience for your visitors. However, keep your visitor’s right to privacy in mind:

  1. Save and use only information that really is to your visitor’s benefit.
  2. Set a reasonable expiration date for all your cookies.
  3. Beware of any third-party code you add to your site. Make sure you aren’t inadvertently adding unwanted cookies.

Cookies really can’t do any harm on your computer or collect any information not already on a page or that you do not enter yourself. But cookies might be used to track your web surfing habits. If you would rather that information be kept private, block cookies or third-party cookies, at the expense of the conveniences those cookies could have given you. If you do not want to block cookies, at least get a good anti-spyware program that will delete the most well-known tracking cookies.

No related posts.

About the Author

Comments are closed.

More Do-It-Yourself Java Games

More Do-It-Yourself Java Games: An Introduction to Java Graphics and Event-Driven Programming is the second book of the Do-It-Yourself Java Games series. You'll learn to create windows and dialogs, to add buttons and input fields, to use images and drawings, and to respond to keyboard input and mouse clicks and drags. You'll create 10 more games including several puzzles, a dice game, a word game, and a card game.

This book assumes you either have an understanding of basic Java programming or you have read the first book, Do-It-Yourself Java Games: An Introduction to Java Computer Programming. Read more.

Do-It-Yourself Java Games

Do-It-Yourself Java Games: An Introduction to Java Computer Programming uses a unique "discovery learning" approach to teach computer programming: learn Java programming techniques more by doing Java programming than by reading about them.

Through extensive use of fill-in blanks, with easy one-click access to answers, you will be guided to write complete programs yourself, starting with the first lesson. You'll create puzzle and game programs like Choose An Adventure, Secret Code, Hangman, Crazy Eights, and many more, and discover how, when, and why Java programs are written the way they are. Read more

Step-by-Step Tutorial

Many of the tips, techniques, and tools discussed in this blog are demonstrated in a detailed step-by-step tutorial in the book, This Little Program Went to Market, by Annette Godtland.

The book takes a computer program through the entire process of creating, deploying and distributing a program, then selling and marketing it (or any other product) on the Internet. Read more.