Loading ...
Sorry, an error occurred while loading the content.

CGI::Cookie question

Expand Messages
  • blu_monk
    Hi folks, I m trying to figure out the best way to create & parse a cookie using the CGI::Cookie module. In the docs[1], it shows how you can create cookies
    Message 1 of 1 , Jan 29, 2002
    • 0 Attachment
      Hi folks,

      I'm trying to figure out the best way to create & parse a cookie
      using the CGI::Cookie module.

      In the docs[1], it shows how you can create cookies like this:
      $cookie1 = new CGI::Cookie(-name=>'ID',-value=>123456);
      $cookie2 = new CGI::Cookie(-name=>'preferences',
      -value=>{ font => Helvetica,
      size => 12 }
      );

      To get the value of $cookie1, you'd use:
      %cookies = fetch CGI::Cookie;
      $id = $cookies{'ID'}->value;

      BUT, it doesn't show you how to get the values out of $cookie2. I've
      tried calls like the following:
      $font = $cookies{'preferences'}->{'font'}->value;
      $font = $cookies{'preferences'}{'font'}->value;
      $font = $cookies{'preferences'}->{font};
      and other variations, but none work. Is there even a way to reference
      these nested cookies this way?

      I'm hoping there's an easy way to reference these nested cookies, as
      I'm used to the easy ASP way, e.g. Request.Cookies("preferences")
      ("font")

      [1] http://www.perldoc.com/perl5.6.1/lib/CGI/Cookie.html

      Any ideas? Many thanks in advance!

      Bill
      b at brilliantcorners.org
    Your message has been successfully submitted and would be delivered to recipients shortly.