Cookies Make the Web Go 'Round
 
SEARCH: webmonkey  the web

 
JavaScript
-------------------------
Print
this article for free. 
-------------------------

Pages:
1  Cookies Make the Web Go 'Round
2 JavaScript cookie sniffer
3 PHP cookie sniffer
4 ASP.NET cookie sniffer

Cookies Make the Web Go 'Round
by Adam DuVander 29 Jun 2006

Adam DuVander [an error occurred while processing this directive]believes life is like eggs in a souffle recipe: Separate the personal from the professional, beat until fluffy, then put them back together. He also likes bad analogies.

Page 1

Here at Webmonkey, we get to tackle all the latest breakthroughs in web development technology. We play around with the newest bits of code and we tell you about them. Sometimes, the newest stuff isn't really so new. Take cookies, for example, the little bits of information that websites store on your computer. We've been writing about them for over a decade.

Cookies let you perform basic identity-based tasks on the web, like logging in to your email account or online banking system. Cookies are essential for maintaining identities during online sessions. You want to make sure that transfer goes to the right off-shore account, after all.

Back in the 1990s, Mark wrote an introduction to cookies and Len talked about what cookies can do for you. Really, cookies haven't changed that much since then. What has happened is that they are used a lot more... by almost every site out there.

Any site that requires a username and password needs a way to remember who you are. Your browser helps websites know who you are after you have logged in. Can you imagine having to enter your password on every page? No fun.

Privacy concerns have kept some users from accepting cookies. Sometimes, problems arise from complex rules to accept cookies from this site, but not that site, or only in certain situations. If your site requires a cookie and the cookie isn't accepted by the browser, the user needs to know. Otherwise, you might leave them logging in repeatedly and never getting anywhere. When that happens, users usually bolt. And you don't want them to leave, because then who's going to fill up your bank account with money and enable you make those transfers to your off-shore accounts?

The best thing to do is check whether the user is accepting cookies right before you actually need them, like on a login page. This way, you can give a nice, human error message that might even explain how to enable cookies.

Sometimes this pre-check is called "cookie sniffing," but I think that sounds dirty. But for lack of a better term, that's what I'll call it. On the following pages, I'll show how to check for whether cookies are enabled in a few popular programming languages: JavaScript, PHP, and ASP.NET.

next page»