|
|
Choosing A Webhost: |
Re: [Boston.pm] Reading Cookies: msg#00098lang.perl.perl-mongers.boston
Thanks for the idea. However, it still does not work. If I use the code that works for all browsers (to write the cookie), then using the CGI.PM method of reading the cookie still does not work. If I use my, more manual, method of creating the cookie (which does NOT work for Safari), then using the CGI.PM method of reading the cookie DOES work. <shrug> Nice thought... Thanks. --Alex Quoting Richard Morse <remorse-zowzMcKzJCVg9hUCZPvPmw@xxxxxxxxxxxxxxxx>: > On Jun 29, 2005, at 12:10 PM, Alex Brelsfoard wrote: > >> OK, so I've filed down my problem. I see where all my confusion has been >> coming. >> Of course I'm still left with one major problem. >> First, here's the situation: >> >> When I use the following code I can write cookies everywhere but in Safari: >> ---------------------------------------------- >> my $cookie = "$COOKIENAME=$cookieContent; " . >> "domain=www.wpi.edu; " . >> "expires=+1h"; >> print "Set-Cookie: $cookie\n"; >> ---------------------------------------------- >> >> After that code I can retrieve the cookie by the following method: >> ---------------------------------------------- >> my %cookies = fetch CGI::Cookie; >> my $userInfo = $cookies{"WPI_REGI2500"}->value; >> ---------------------------------------------- >> >> Interesting fact, I cannot use this same code to read any other >> random cookie I >> see in my browser (testing with Firefox). >> >> OK, Now, my fixed code to be able to write cookies in any browser is >> as follows: >> ---------------------------------------------- >> my $cookie = $q->cookie( -name => $COOKIENAME, >> -value => $cookieContent, >> -domain => "www.wpi.edu", >> -expires => "+1h", >> -path => "/cgi-bin/Regi", >> -secure => 1 ); >> print "Set-Cookie: $cookie\n"; >> ---------------------------------------------- >> >> However, once I write the cookie this way, my cookie retrieval function no >> longer works. I have verified that the cookie IS there. And it >> looks exactly >> the same as with the other code. But I simply can't read the cookie. >> I have tried reading the cookie in several different ways, including reading >> from $ENV{"HTTP_COOKIE"}, and doing both "fetch CGI::Cookie" and "parse >> CGI::Cookie". >> I MUST be reading in these cookies incorrectly in some way. >> Can anyone help me, or point me in any helpful direction (other than >> the pub)? >> > > If you are using the OO interface to CGI.pm, the docs (`perldoc CGI`) > say that you should do the following: > > Create a cookie using: > > my $cookie = $q->cookie(-name=>'name', -value=>'value' ...); > print $q->header(-cookie=>$cookie); > > [read the docs for the specifics on this; you may need to pass other > values to the cookie call, and there are ways to set multiple cookies] > > To retrieve the cookie, use the cookie() method _without_ setting a > value: > > my $val = $q->cookie('name'); > > Does this work? > > Ricky > >
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [Boston.pm] Reading Cookies, Richard Morse |
|---|---|
| Next by Date: | Re: [Boston.pm] Reading Cookies, Kenneth A Graves |
| Previous by Thread: | Re: [Boston.pm] Reading Cookies, Richard Morse |
| Next by Thread: | Re: [Boston.pm] Reading Cookies, Kenneth A Graves |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |