Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Receiving Cookie Values

by dingus (Friar)
on Dec 04, 2002 at 15:48 UTC ( [id://217513]=note: print w/replies, xml ) Need Help??


in reply to Receiving Cookie Values

Weeellllll, you have to set the cookie in the HTTP header not in the body of the HTML document. So that means you have to do the print header() after the cookie setting stuff. Try
my ($usr,$pw); if ($ENV{'HTTP_COOKIE'}) { $usr = $wm->cookie('user'); $pw = $wm->cookie('pass'); } else { $usr = $wm->param('usr'); $pw = $wm->param('pw'); } print $wm->header(-cookie=>[$usr, $pw]);
Also take a look at the CGI.pm docs and examples - especially the cookie setting one

Dingus


Enter any 47-digit prime number to continue.

Replies are listed 'Best First'.
Re: Re: Receiving Cookie Values
by Jaspersan (Beadle) on Dec 04, 2002 at 21:05 UTC
    That didnt work either, here is what the browser says when It prompts to accept the cookie:

    ---
    This page wishes to set the cookie
    wintermarket_members_user="%24user"
    ---
    And its the same thing with the password =\

    I noticed in the 'cookie setting example' that you linked to, it escaped out the hash like so:
    $the_cookie = cookie(-name=>'animals', -value=>\%zoo, -expires=>'+1h');
    Could this have anything to do with it?

    Here is my code:
    my ($usr,$pw); if ($ENV{'HTTP_COOKIE'}) { # from cookie $usr = $wm->cookie('wintermarket_members_user'); $pw = $wm->cookie('wintermarket_members_pass'); } else { # from form $usr = $wm->param('usr'); $pw = $wm->param('pw'); } &set_cookie($usr,$pw,$wm); #... in set_cookie sub my $cookie_usr = $input->cookie(-name=>'wintermarket_members_user', -value=>$usr, -expires=>'+1h'); my $cookie_pw = $input->cookie(-name=>'wintermarket_members_pass', -value=>$pw, -expires=>'+1h'); print $input->header(-cookie=>[$cookie_usr,$cookie_pw]);
    But thanks for the help dingus :)
    ^jasper
      This page wishes to set the cookie
      wintermarket_members_user="%24user"

      OK - %24user is the escaped version of $user. So I think somewhere you are setting the parameter $usr to '$user' not to "$user"

      I think your cookie setting code looks OK. Its that you are settign the wrong values somehow. have you checked the values of param('usr') and param('pw') ?

      Dingus


      Enter any 47-digit prime number to continue.
        Hrmm, i posted couple days ago, but i guess it didnt post... *shrugs*

        That code worked, thanks :)

        ^jasper
        Nevermind, It works now.
        Yeah, I've checked the params and they were the username and password. Still don't know why it was setting the escaped $user/$pass, but its working now.

        Thanks for the help :)
        ^jasper <jasper@wintermarket.org>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-03-28 23:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found