Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Apache2::REST cookie retrieve

by gman (Friar)
on Aug 21, 2017 at 19:43 UTC ( [id://1197757]=perlquestion: print w/replies, xml ) Need Help??

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

Hello Monks,

I am working with Apache2::REST, and can't seem to retrieve cookies from the request headers.
Apache2::REST::Request requires the $r request object, however i think Apache2::REST sub GET {  my ($self, $request, $response) = @_ ; } $request is only the URL parameters.

I have tried variations of the following;

my $req = Apache2::Request->new($request->{r}); my $j = Apache2::Cookie::Jar->new($req); my @attESSec = $j->cookies();

I know i'm not connecting the dots here, any help would be greatly appreciated!

Thanks,

UPDATE

This is the easiest way I found to solve the issue;

sub GET { my ($self, $request, $response) = @_ ; my $c = $request->connection; my $cookies = $request->headers_in->{Cookie}; my %cookies = map { split(/=/) } split(/;/,$cookies);

I tried feeding $c and $cookies into Apache2::Cookie without luck

PS. Whats with my Submit button saying stumbit? s/stumbit/submit/ ?

Replies are listed 'Best First'.
Re: Apache2::REST cookie retrieve
by beech (Parson) on Aug 21, 2017 at 22:21 UTC

    Hi,

    Apache2::Cookie says

    $j = Apache2::Cookie::Jar->new($request); ## instead of $request-> +{r} $c_in = $j->cookies("foo"); # get cookie from request head +ers

    But, maybe consider a different framework ( Mojolicious or Dancer ... )

    Also Just a little note - "stumbit" instead of "submit"

    update: hehe, I see you already tried that, I got confused

    oh, I see it was almost, try $request instead of $request->{r}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1197757]
Approved by beech
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 10:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found