Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Apache2::Cookie troubles... sanity check needed on auth/sess handling

by clinton (Priest)
on Apr 04, 2006 at 08:28 UTC ( #541094=note: print w/ replies, xml ) Need Help??


in reply to Apache2::Cookie troubles... sanity check needed on auth/sess handling

A quick grok of your code suggests that the problem is here :

Apache2::Cookie->new ( $r, -name => 'user_login', -value => { user_id => $ARGS{username}, MAC => $MAC }, -path => '/', -domain => 'ruth.dobson.net', -expires => '+1M', )->bake($r); $url= "/test.html"; $m->redirect($url);

Calling cookie->bake puts your cookie headers the response headers, but then you request a redirect, which is not a 200 response, and so the standard page headers do not get sent.

Instead of using bake, you need to set your err_headers_out, which will get sent regardless of the response code.

See here for a recipe : Sending Cookies in REDIRECT Response handlers


Comment on Re: Apache2::Cookie troubles... sanity check needed on auth/sess handling
Download Code
Re^2: Apache2::Cookie troubles... sanity check needed on auth/sess handling
by jimbus (Friar) on Apr 04, 2006 at 17:59 UTC

    Based on the recipe, I updated the following to the login page

    if ($res->{res}) { my $MAC = Digest::SHA1::sha1_hex($ARGS{username}, "Get the S1gnal!") +; my $cookie = Apache2::Cookie->new ( $r, -name => 'user_login', -value => { user_id => $ARGS{username}, MAC => $MAC }, -path => '/', -domain => 'ruth.dobson.net', -expires => '+1M', ); $r->err_headers_out->add('Set-Cookie' => $cookie); }

    It didn't change any thing. is there any way to, if I stop before the redirect, to check and see what whas set or check someplace to see what is happening when I submit the cookie? I'm not sure how to go about debugging this.


    --Jimbus aka Jim Babcock
    Wireless Data Engineer and Geek Wannabe
    jim-dot-babcock-at-usa-dot-com
      $r->err_headers_out->add('Set-Cookie' => $cookie->as_string);
      To debug cookie problems, use a browser that shows the headers (lwp-request, Firefox with LiveHTTPHeaders, a logging proxy).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://541094]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (12)
As of 2014-12-21 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls