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

Re: Just Another Question About Sessions And User Management

by skx (Parson)
on Sep 26, 2005 at 11:26 UTC ( [id://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
--

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-04-16 09:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found