Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://495066]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2018-03-23 02:00 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (287 votes). Check out past polls.