in reply to Serializing Cookies ???
and this to retrieve the cookie.#!/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;
Update:#!/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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Serializing Cookies ???
by lindex (Friar) on Dec 06, 2000 at 03:11 UTC |