|
|
|
| |
Stay up-to-date! Subscribe to our
newsletter. |
| |
|
How to use cookies in your Perl scriptsDateline: 03/14/00
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
use cookies.
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
'1234'.
You can also save information about the cookie, such as
- 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
A fully specified cookie looks something like this:
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,
3,
4
|
Email
this page!
| Sponsored Links |
WebContactPro-
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. http://www.webcontactpro.com/ (Listing
fee: $0.38) |
Techies.com 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. http://techies.com/ (Listing
fee: $0.37) |
Find
Practically Anything on Earth at
eBay! 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 http://cgi.ebay.com/ (Listing
fee: $0.30) |
The
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. http://www.jspin.com/ (Listing
fee: $0.16) |
Advanced
Minds Internet Solutions Offers domain name
sales, virtual hosting, dedicated hosting, NT hosting and
other internet needs. http://www.advancedminds.com/ (Listing
fee: $0.15) |
|
| |
|
|
|
| Related Sites |
 |
| from About & Partners |
|
|
 |
|
|
| |
|