Now that you've mastered advanced string handling and
associative
arrays,
it's time to open up the cookie jar. As I mentioned
earlier,
cookies are
little bits of information that you can leave on
a user's
hard drive,
where they stay even after the user leaves your site or turns off the
computer, which is extremely
useful when you want to remember information
about repeat visitors.
Before we start, here's a
caveat. Cookies were introduced
in Netscape 2.0
and MSIE 3.0.
Unfortunately, the MSIE 3.0 implementation
of cookies is
somewhat flawed.
While you can use cookies to save and read
information on other
computers, you can't save
cookies to
your own computer, which makes
it really hard to test your cookie
code. So, if you're using MSIE 3.0, it's probably time to
upgrade to the most recent version of MSIE or switch to Netscape.
That said, let's look at a basic example
of a working cookie.
In
this example, we set a cookie on one page and then
read it
from another
page. As you play around with the example, try to
think about how you would
do this without cookies.
Here's the very
basic example of a
working
cookie.
Had your fill of cookie dough tasting? Let's move on
to
the next step of the recipe.
next page»