Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

session script

by rjsaulakh (Beadle)
on Jun 08, 2005 at 11:21 UTC ( [id://464634]=perlquestion: print w/replies, xml ) Need Help??

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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: session script
by Fletch (Bishop) on Jun 08, 2005 at 12:28 UTC

    To quote the bowl of petunias, "Oh no, not again."

    --
    We're looking for people in ATL

Re: session script
by atcroft (Abbot) on Jun 08, 2005 at 12:48 UTC

    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.

      the following code poses some syntax error need some help
      printf <<TEST, join ( "<BR>\n", map { $_ . " -&gt; " . $cookies{$_} } sort +keys %cookies ); %s TEST
      .
        #!/usr/bin/perl use strict; use warnings; my %cookie = ( one => 1, two => 2, ); for my $key (sort keys %cookie){ my $value = $cookie{$key}; print "$key $value </br>\n"; }
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: session script
by terce (Friar) on Jun 08, 2005 at 11:37 UTC
    Please encapsulate this with an explanation or at least a link to another node - it'll be meaningless to anyone who hasn't been logged in and watching the CB.
Re: session script
by TheStudent (Scribe) on Jun 08, 2005 at 12:05 UTC
    and your question is?

    TheStudent

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://464634]
Approved by tcf03
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2024-03-28 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found