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

Hi guys,

I have been using Matt Wright's cookie.lib file up until now and it is causing several problems :( so I want to re-do my code to change it to use the cgi.pm cookie features, what I really would like to know is that is there anyway I can keep my current setup, at the moment I referance the cookies throughout my script $Cookies{'username'} I would hate to go through and update it all, is there anyway to retrieve cookies and store them the same way with cgi.pm?

Any help is very appreciated, Have a great christmas

Jon

Replies are listed 'Best First'.
Re: Cookie CGI.PM
by jryan (Vicar) on Dec 20, 2001 at 06:34 UTC

    Matt Wright's cookie.lib

    Arrrrggh... will the madness never end?

    I didn't even know that he had more scripts outside of his "repository." Are these scripts the ones from his book? I thought no one used those... Blast!

    The NMS project is currently replacing all of Matt Wright's scripts. Many of the replacements are nearing their final stages (with the exception of formmail (good god, the nightmares!), guestbook, and WWWBoard), and the project is looking towards expanding into other scripts outside of those replacing the MWS repository. I'm sure that NMS will eventually replace the scripts from his book, but until then, use CGI::Cookie for all of your cookie needs.

      I would have to disagree - don't use CGI::Cookie, stick with CGI.pm and use the cookie methods from there. I've had no end of problems with CGI::Cookie that disappeared immediately that I stuck with CGI.

      Just my two penneths worth :)
Re: Cookie CGI.PM
by reyjrar (Hermit) on Dec 20, 2001 at 04:45 UTC
    Well, you should be managing all your cookies, so here's the quickest way I can think of:
    use CGI; my $c = CGI->new(); # Make a list of all our cookies; my @_COOKIES = qw(cookie1 cookie2 cookie3); my %COOKIES = (); foreach my $cookie (@_COOKIES) { my $value = $c->cookie($cookie); $COOKIES{$cookie} = $value if $value; }

    That's a pretty quick, cheap hack but should work..

    -brad..