[thelist] cookies in perl/cgi

Anthony Baratta Anthony at Baratta.com
Sun Jul 23 20:08:14 CDT 2000

Adrian Fischer wrote:
> Thanks Anthony,
> I did this :
> > Replace {'lib/biccyset.pl';}
> > with
> > {print "Location: lib/biccyset.pl\n\n";)
> But all it does it print the phrase within "" to the screen.  Not the result
> I was after.  This has to be the most frustrating thing Ive ever tried to
> do...how hard can it be to set a cookie in perl/cgi????

Its not - but its not the easiest thing in the world either. First off - are you
printing ANYTHING else to the browser before this statement?? The Location:
"redirection" must be the first, and only thing you send to the browser. 

Here is how I set cookies in Perl....

  #Setting Cookie
  print "Content-type: text/html\n";
  print "Set-Cookie: CookieName=Value; expires=$varGMTExpireDate GMT;path=/; \n\n";

First, note we only use ONE \n after the content type, and two after the Set-Cookie.
Also, the expires date MUST be in Greenwich Meantime. Lastly, you MUST have a path
for IE to accept the cookie correctly.
Anthony Baratta
KeyBoard Jockeys
                    South Park Speaks Version 3 is here!!!
                              Powered by Tsunami

More information about the thelist mailing list