Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Just Another Question About Sessions And User Management

by skx (Parson)
on Sep 26, 2005 at 11:26 UTC ( #495066=note: print w/ replies, xml ) Need Help??


in reply to Just Another Question About Sessions And User Management

Here is a small example:

#!/usr/bin/perl -w -I. use strict; use CGI; use CGI::Cookie; use CGI::Carp qw/ fatalsToBrowser /; # TODO - Hide errors. use CGI::Session; # # New CGI object; used to get access to the cookie(s). # my $q = new CGI; # # Get a CGI::Session object - either completely new, or one previousl +y # associated with the given cookie. # my $session = CGI::Session->new( 'driver:File', $q->cookie('CGISESSID') || $q->param('CGISESSID') || +undef, { Directory => '/tmp' } ) or die ($CGI::Session::errstr); # # Identifier for this session. # my $sessionid = $session->id(); # # Retrieve "count" from it. # my $count = $session->param("count") || "1"; # # Update the count in the session # $session->param( "count", ($count+1) ); # # Print a sample page showing the visited count: # print "Set-Cookie: " . $q->cookie( -name => 'CGISESSID', -value => $sessionid, -expires => '+1d', -path => '/' ) . "\n"; print "Content-type: text/plain\n\n"; print "You've been here $count times before\n";
Steve
--


Comment on Re: Just Another Question About Sessions And User Management
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://495066]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2014-11-27 10:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (183 votes), past polls