Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

cookie retrieval

by costas (Scribe)
on May 18, 2001 at 08:44 UTC ( [id://81450]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

costas has asked for the wisdom of the Perl Monks concerning the following question:

I am using this to retrieve values from a multiple cookie

my $cookie_value = fetch CGI::Cookie;
only problem is that that the results that it brings back appear like this

$cookie_value->{'name'} = name=value;path=\

I then have to perform split function to extract value.
how can you retrieve JUST the value in a hash set?

THanks

Replies are listed 'Best First'.
Re: cookie retrieval
by mpolo (Chaplain) on May 18, 2001 at 10:55 UTC
    You're reading the cookie into a scalar variable rather than a hash. If you change this to
    my %cookie_value=fetch CGI::Cookie;
    you will have it in a hash, so that $cookie_value{'name'} will indeed be equal to 'value'.

    So, in essence, one punctuation error was the difference between success and failure.

Re: cookie retrieval
by DrZaius (Monk) on May 18, 2001 at 16:25 UTC
    If you are 'use CGI; my $cgi = CGI->new'ing, you can do this instead:
    my $cookie_a = $cgi->cookie('a');

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://81450]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.