Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: [Boston.pm] Reading Cookies: msg#00098

lang.perl.perl-mongers.boston

Subject: Re: [Boston.pm] Reading Cookies

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>
Google Custom Search

Recently Viewed:
user-groups.jax...    php.zend.framew...    os.solaris.open...    web.quixote.use...    java.openjdk.ho...    ietf.secmech/20...    gnu.glpk/2004-0...    recreation.cars...    network.smokepi...    linux.drivers.i...    cms.opencms.dev...    fonts.gfontview...    text.xml.soap.u...    voip.nist-sip/2...    debian.ports.hp...    xfree86.interna...    science.biology...    qnx.openqnx.dev...    mail.sylpheed.c...    busybox/bios/20...    emulators.kvm.s...    hardware.openco...    apple.fink.begi...    kde.german/2006...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive 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

Navigation