LanguagesChecking out your Cookies' Crumbs

Checking out your Cookies’ Crumbs

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Many web sites that you visit create and leave behind small files called cookies on your system. When you revisit the site, the cookie can be read and information restored. This allows a site to keep track of customized information specific to you.

It is very easy to see what information is stored in your cookies. This can be done by entering a single line of code into the address entry box of your browser.

First go to a site. Once at that site, enter the following into the address box:

javascript:alert("Cookie:"+document.cookie)

This is actually a small piece of JavaScript that you are running. The javascript: indicates to your browser that it is about to get a piece ofJavaScript code. The alert is a JavaScript command that pops up a dialog box. When you run this program, the cookie information will be put into a pop-up window like the following:

The "Cookie:" is text that will be printed within the dialog box. You can see this text is printed in the above dialog. Added to this text is the information contained in document.cookie.The actual text of the cookie is actually contained within document.cookie.

That is it! Put one line of code into the address box, press Enter, and there you have it. If you are on a site that doesn’t use cookies, you will get a dialog with just the “Cookie:” text. Following is the dialog I received fromthis site, www.developer.com,using Internet Explorer:

Want to try it out? Go to some of your favorite sites and give it a try. I tried a few sites. Cookie information is personal so I’m not going to display the results. The following are a few sites that use cookies that you can take a look at:

http://www.asp101.com/ 
http://www.thinkmobile.com/ 
http://www.networksolutions.org/ 
http://www.sun.com 
http://www.microsoft.com 
http://www.ibm.com 
http://www.amazon.com 

For even more fun, try looking for cookies with different browsers. NetscapeNavigator and Microsoft Internet Explorer can show different cookie information!

Note: If your browser has cookies turned off, then obviously, you won’t have cookies anywhere!

# # #

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories