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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Cookies for a Project
by nysus (Parson) on Jun 12, 2001 at 06:05 UTC
    You'll want to visit: http://stein.cshl.org/WWW/software/CGI/#cookies

    Update: My advice only applies if you are using CGI.pm, of course. But there is no way for me to know what you are doing...

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot";
    $nysus = $PM . $MCF;

    Ahh ok
    by Cobo (Scribe) on Jun 12, 2001 at 06:18 UTC
      ok, i'll be using perl to print html. sorry about the lack of information in my previous post
        As implied in nysus' reply, you really want to be using the module CGI.pm in this project. There is a submodule called CGI::Cookie, which specifically does what you want: reads the cookies -- you can either create a hash or leave them in the CGI object and read them off as you need them. In any case, check out Use CGI or die; on this site to see why this module is such a good idea.
(jeffa) Re: Cookies for a Project
by jeffa (Bishop) on Jun 12, 2001 at 19:04 UTC
    Here is a cookie example i wrote a little while ago, maybe this will give you an idea:
    use strict; use CGI; use CGI::Cookie; my $CGI = new CGI; my %cookies = fetch CGI::Cookie; # get the old cookies my $i = 0; $i = $cookies{'i'}->value + 1 if defined $cookies{'i'}; # create new cookie to hold value my $cookie = $CGI->cookie( -name => 'i', -value => $i, ); # and this makes it all work print $CGI->header(-cookie=>$cookie), "i is now $i";
    Just keep reloading the page to watch it count up.

    Jeff

    R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
    L-L--L-L--L-L--L-L--L-L--L-L--L-L--