in reply to Re^2: Baking Cookies and Eating them
in thread Baking Cookies and Eating them

What doesn't work?
What do you get?
What was the code you used (preferably just the section in question)?
Have you read How (Not) To Ask A Question?

Try dumping the value returned and see what you get.

use Data::Dumper; my %cookie_value = $cookies{'LSRfm'.$type}->value; print qq|<pre>|; print Dumper \%cookie_value; print qq|</pre>|;


grep
Mynd you, mønk bites Kan be pretti nasti...

Replies are listed 'Best First'.
Re^4: Baking Cookies and Eating them
by barrycarlyon (Beadle) on Sep 30, 2006 at 22:03 UTC

    Data Dump

    $VAR1 = { '{ username => barrycarlyon, password => 025a38ae929ace0637824f7728da371d }' => undef };

    code:
    sub _cookie { #read in the lsrfm cookie to test my $self = shift; # my $cgi = CGI->new; # my $type = $cgi->param('type'); my $type = shift; #lets check to see if the lsrfm cookie exits #fecth the domains cookie my %cookies = fetch CGI::Cookie; my $cookies; my $lsrfm_cookie; if (!%cookies) { #a domain cookie doesnt exist #leave as blank } else { #a domain cookie exists #fetch the type value my $n = 0; my $this_cookie; my @cookies = (keys %cookies); foreach (keys %cookies) { $this_cookie = $cookies[$n]; if ($this_cookie eq ('LSRfm'.$type)) { $lsrfm_cookie = $cookies{'LSRfm'.$type}->value; } $n ++; } } use Data::Dumper; my %cookie_value = $cookies{'LSRfm'.$type}->value; print qq|<pre>|; print Dumper \%cookie_value; print qq|</pre>|; exit; return $lsrfm_cookie; }
    Barry Carlyon barry@barrycarlyon.co.uk

      right off the bat i'd like to say i'd NEVER put a parameter in a cookie called "password". if that gets intercepted, you've made it all to easy (encrypted or not) for someone to get ahold of a users password.

      meh.
      Thanks.

      So $cookies{'LSRfm'.$type}->value returned a hash ref. Which I guess, means I didn't read the docs right.

      What do you get with

      use Data::Dumper; my $cookie_value = $cookies{'LSRfm'.$type}->value; print qq|<pre>|; print Dumper $cookie_value; print qq|</pre>|; exit;


      grep
      Mynd you, mønk bites Kan be pretti nasti...

        I found a problem with my cookie, i tested using the dual value in the example on cpan, the data dumper is:

        $VAR1 = { 'password' => '025a38ae929ace0637824f7728da371d', 'username' => 'barrycarlyon' };
        but with font and size, (note speechmarks, and values are on two lines not one)
        so I corrected my cookie creation, and will now try your solution again
        Barry Carlyon barry@barrycarlyon.co.uk