Hello,
You should check out CGI::Application.
I put this example on the CGI::Application wiki a while ago. It abstracts the use of CGI::Application to a single use() statement:
#!/usr/local/bin/perl use warnings; use strict; TestApp->new->run; package TestApp; use base qw|CGI::Application|; use CGI::Application::Plugin::AutoRunmode; use CGI::Application::Plugin::Session; sub default : StartRunmode { my $self = shift; my $output; # get current access count my $access_count = $self->session->param('access_count') || 0; # increment access count $access_count++; # store new access count in session $self->session->param(access_count => $access_count); # get CGI object out of application my $q = $self->query; #build output $output = $q->start_html( -title => 'access count application'); $output .= $q->div("accessed $access_count time(s) this session"); $output .= $q->div($q->a({-href => $q->self_url}, 'access again')); $output .= $q->end_html; # give output to app to send to user return( $output ); }
This code simply increments a session counter each time the user accesses the page.
In your code, you'd make a login and an options runmode (method). In the login runmode, put the user's database id in the session upon successful login. In the options runmode, check to see if the user's id is in the session (and valid!) before continuing.
Enjoy
trwww
In reply to Re: CGI::Session Usage Doubt
by trwww
in thread CGI::Session Usage Doubt
by poolboi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |