Subscribe to our
IntroductionUp until now most of the articles on this site
have focused on simple scripts that accomplished simple tasks.
At most we have saved data to a file or a database, but none of the
examples has shown you how to maintain state between sessions.
Why would you want to do that? Well, if you're writing a
guestbook script, you wouldn't really need to. A person visits
your site, gives you their information, and sees the result when you
print the new guestbook. But if you want to personalize your
site in any way then you'll have to know about how to save
information between pages or sessions. For example, if you
wanted to create a site that lets users pick and choose what to
view. Or maybe you'd like to write an online ordering
system. Or you need some way to track activity on your web
site. How would you do that? One easy way to do it is to
What is a cookie?A cookie is a chunk of information that
you're allowed to save on a client computer. Normally, for
security reasons, you are not allowed access to computers that visit
your web page. However, cookies are an exception that allow
you to save information on someone's computer in a structured and
somewhat limited fashion.
What does a cookie look like?A cookie consists of a
"name=value" pair, such as
USER_ID = 1234
In this case, the cookie is named 'USER_ID', and the value is
You can also save information about the cookie, such as
A fully specified cookie looks something like this:
- The cookie's expiration date and time
- The valid domain for the cookie
- The valid server path for the cookie
- Whether or not to use a secure channel for the cookie
TEST_COOKIE=Famous%20Amos; domain=.mydomain.com; path=/;
expires=Sat, 11-Mar-2000 22:52:37 GMT; secure
Cool. Now that you know what a cookie looks like, the next
step is to show you how to set and get them from your scripts.
Don't worry, its easy. We'll use CGI.pm to do it for us.
Next Page How
to set cookies with CGI.pm > Page 1, 2,
Smartest Way To Grow E-Business|
Built-in shopping cart,
unlimited autoresponders, list manager, form processor,
database marketing, ad tracking, affiliate tracking,
electronic coupon system and more.
The leading career
resource for technology professionals in the country. Find the
hottest tech jobs. Online training. Valuable career tips. And
the inside scoop on local companies.
Practically Anything on Earth at
eBay - the world's
largest online trading site where people buy, sell or trade
practically anything on earth. Over 4 million items available
in over 4,000 categories including perl
JSP Resource Index|
The most comprehensive,
searchable index of JavaServer Pages applications, beans,
scripts, tutorials and references. Arranged by reviews,
ratings, price, version, hits and more.
Minds Internet Solutions|
Offers domain name
sales, virtual hosting, dedicated hosting, NT hosting and
other internet needs.
|from About & Partners|