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 { $_ . " -&gt; " . $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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.