Apache-SessionManager
view release on metacpan or search on metacpan
SessionManager.pm view on Meta::CPAN
lock directories:
PerlSetVar SessionManagerStoreArgs "Directory => /tmp/apache_sessions, \
LockDirectory => /tmp/apache_sessions/lock"
If you use MySQL for your datastore, you need to pass database connection
informations:
PerlSetVar SessionManagerStoreArgs "DataSource => dbi:mysql:sessions, \
UserName => user, \
Password => password"
Please see the documentation for store/lock modules in order to pass right
arguments.
=item C<SessionManagerItemExclude> string|regex
This single directive defines the exclusion string. For example:
PerlSetVar SessionManagerItemExclude exclude_string
SessionManager/cookpod.pod view on Meta::CPAN
return FORBIDDEN;
}
$session->{'logged'} = 1;
# Redirect to original protected resource
$r->content_type('text/html');
$r->header_out( Location => $session->{'redirect'} );
return REDIRECT;
}
# Check correct username and password with your own policies
sub verifiy_cred {
my %cred = @_;
return 1 if ( $cred{'username'} eq 'foo' && $cred{'password'} eq 'baz' );
return 0;
}
1;
Now we write an essential login form code
F</usr/local/apache/htdocs/protected/login.html> (save it according to
C<PerlSetVar MyAuthLogin> setting):
<HTML>
<BODY>
<FORM METHOD="GET">
<INPUT TYPE="test" NAME="username" SIZE="10">
<INPUT TYPE="password" NAME="password" SIZE="10">
<INPUT TYPE="submit" VALUE="Login">
</FORM>
</BODY>
</HTML>
=head3 NOTE ON CUSTOM ERROR MESSAGE WITH MSIE
The recently released version of Microsoft's Internet Explorer (from 5.x) has
some new "features" (?) which may affect sites.
SessionManager/cookpod.pod view on Meta::CPAN
=head1 USING Apache::SessionManager AND Apache::DBI
=head2 INTRODUCTION
This section describes how to use
L<Apache::SessionManager|Apache::SessionManager> with
L<Apache::DBI|Apache::DBI> when using a RDBMS for sessions back-end datastore.
L<Apache::DBI|Apache::DBI> is a useful mod_perl module that caches database
connections according to args (like DBD driver, user, password) and attributes.
So, if your application uses a different user and/or attributes to connect to a
(different) database, every connection will be cached. Also, every child could
have these cached DB's handles. L<Apache::DBI|Apache::DBI> works very well for
web applications that uses same DB user.
=head2 CONFIGURATION
There is no need of extra configuration steps to use advantage of persistent DB
connections offered by L<Apache::DBI|Apache::DBI> when using
L<Apache::SessionManager|Apache::SessionManager> with a RDBMS as session
t/lib/MyAuth.pm view on Meta::CPAN
$r->headers_out->{'Location'} = $session->{'redirect'};
return MP2 ? Apache::REDIRECT : Apache::Constants::REDIRECT;
}
sub verifiy_cred {
my %cred = @_;
#use Data::Dumper;
#print STDERR Dumper(\%cred);
# Check correct username and password
return 1 if ( $cred{'username'} eq 'foo' && $cred{'password'} eq 'baz' );
return 0;
}
1;
t/protected/login.html view on Meta::CPAN
<HTML>
<BODY>
<FORM METHOD="GET" ACTION="">
<INPUT TYPE="test" NAME="username" SIZE="10">
<INPUT TYPE="password" NAME="password" SIZE="10">
<INPUT TYPE="submit" VALUE="Login">
</FORM>
</FORM>
<BR>
</BODY>
</HTML>
( run in 0.480 second using v1.01-cache-2.11-cpan-49f99fa48dc )