Welcome back. Now that your brain has re-acclimated to the semicolons
and curly braces of the JavaScript world, it's time to learn something
useful and exciting.
We'll spend this lesson sampling those tasty treats known as cookies the little bits of information you can leave on the computers of people who visit your site. Cookies allow you to give your pages a personal touch. For instance, with a cookie you can "remember" people's names and serve up a warm greeting every time they re-visit. You can also remember user preferences if a visitor generally comes in on a slow connection, a cookie lets you know to automatically serve them minimal graphics.
Cookies can be very useful and sometimes scary: When I buy airplane tickets online, the service I use remembers not only my name, but also where I live and my seating preferences. It even knows who I traveled with last and asks if that person will be joining me on my next flight. There's a fine line between useful and invasive.
As long as you use them responsibly and effectively (and don't freak anyone out with Big Brother knowledge), cookies can be extremely handy for all sorts of reasons. So I'm going to show you how they work. But before we get our hands all doughy, we should cover two JavaScript topics: fancy string handling and associative arrays.
next page»