This code seems to work for me if I change from nfreeze to freeze as in the code below. I'm not sure what your error means, I was unable to duplicate it. Here are two scripts that I put together to test these routines.
HTH
#!/usr/bin/perl -w
use CGI;
use Storable qw(freeze);
my $q = CGI->new();
sub make_cookie {
$q->cookie( -name=>'Test',
-value=>unpack("H*",freeze(['1245','foo','foopass'])),
-path=>'/' );
}
print $q->header(-cookie=>make_cookie());
print $q->start_html(-title=>'Test cookie');
print "Cookie Set<br>";
print $q->end_html;
and this to retrieve the cookie.
#!/usr/bin/perl -w
use CGI;
use Storable qw(thaw);
my $q = CGI->new();
sub see_cookie {
@{ thaw( pack("H*",$_[0]) ) };
}
print $q->header();
print $q->start_html(-title=>'Test cookie');
print "Cookie Value: ", (join " -- ", see_cookie($q->cookie('Test')) )
+, "<br>";
print $q->end_html;
Update:
I tried these scripts under mod_perl also and they work in that enviorment also (Apache::Registry), I would take a look at your Storable module.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.