magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 1998 > 12 > Programming with Perl  

Making a Cookie Jar

Ahh, cookies. Not one of my favorite subjects. Cookies, I've decided, are generally mostly evil. Every site I've visited seems to want to send me cookies (as Internet Explorer is happy to report). For the most part, they want to do things like target advertising at me, or even see how often I've been to their particular site.

And more and more, cookies are being used to identify me as a particular person to trigger access to customized features (like my.yahoo.com or my online banking service). And that's annoying. Why? Because I use a half-dozen browsers (if you count agents made from Perl scripts) in a day, and cookies are associated with a particular browser, not a particular person.

So, what to do? I need to have a cookie jar that holds all my cookies. I thought a bit about it, and came up with an interesting approach. What if I were to direct all my Web requests through a proxy server, which could extract cookies from the responses, and add the right cookies to future requests? Aha! That would solve it.

Now, I've already written a Perl proxy server (which I discussed in this column in the February 1997 issue), and I could have wired my cookie jar into that server and kept it running. But some of the browsers I use are located at client sites where I'm teaching or consulting, and it's not always possible to change their proxy settings in a way that would work.

So I took a different approach: a "poor man's proxy," handled entirely as a CGI script! I'd simply invoke the script, extending the URL of the script to include the URL of the page I wanted to fetch, and the program would fetch the page, handling the incoming and outgoing cookies.




  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2