Perhaps the following code segment will suggest something to you. In the segment (which was in my /cgi-bin/ path when testing, thus the path values in the cookies), I set cookies if not previously set, retrieved the cookies' values if they existed, and printed them using Data::Dumper for examination.
#!/usr/bin/perl use strict; use warnings; use CGI; use CGI::Cookie; use CGI::Session; use Data::Dumper; my $q = new CGI; my $session = new CGI::Session( undef, $q, { Directory => q{/tmp'} } ); $Data::Dumper::Sortkeys = 1; my %cookies = fetch CGI::Cookie; my (@cookielist); my $t = ( !exists( $cookies{settime} ) ) ? time() : $cookies{settime}->value; push @cookielist, new CGI::Cookie( -name => 'test', -path => q{/cgi-bin/}, -value => ( !exists( $cookies{test} ) ? scalar gmtime : $cookies{test}->value ) ); push @cookielist, new CGI::Cookie( -name => 'settime', -path => q{/cgi-bin/}, -value => ( !exists( $cookies{settime} ) ? $t : $cookies{settime}->value ) ); push @cookielist, new CGI::Cookie( -name => 'difftime', -path => q{/cgi-bin/}, -value => time() - $t ); print $q->header( -cookie => \@cookielist ); print qq{<html>\n<body>\n}; printf <<TEST, join ( "<BR>\n", map { $_ . " -> " . $cookies{$_} } sort +keys %cookies ); %s TEST print qq{<pre>\n}; print Data::Dumper->Dump( [ \%cookies, \@cookielist ], [qw(*cookies *cookielist)] ); print qq{\n}; print qq{</pre>\n}; print qq{</body>\n</html>\n};
Hope that helps.
In reply to Re: session script
by atcroft
in thread session script
by rjsaulakh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |