Apache-Session
view release on metacpan or search on metacpan
- semaphore tests check for semctl availability
- Makefile.PL prints message if perl version < 5.006
1.86 2008-02-01 by Alexandr Ciornii
- Default number of semaphores for *BSD is 8 in Apache::Session::Lock::Semaphore
1.85_01 2008-01-24 by Alexandr Ciornii
- typos corrected (catched by Gerald Fox)
- more tests and diag in 99semaphore.t
- no warning "disconnect invalidates 2 active statement" in
Apache::Session::Lock::MySQL by Tony Cook (RT#32148)
1.85 2007-12-20 by Alexandr Ciornii, Perl 20th birthday version
- mention Catalyst::Plugin::Session, Session
1.84_01 2007-11-26 by Alexandr Ciornii (alexchorny AT gmail.com)
- Added Apache::Session::Lock::Semaphore::remove to remove semaphore
- 99flex.t will remove semaphore (RT#30440)
- 99flex.t should work on 5.6.1 again (no chdir now)
- 99flex.t will clean all temporary files (RT#30209)
- pod.t included in MANIFEST
lib/Apache/Session.pm view on Meta::CPAN
cookies to generate and maintain session IDs.
use Apache::Session::MySQL;
use Apache;
use strict;
#read in the cookie if this is an old session
my $r = Apache->request;
my $cookie = $r->header_in('Cookie');
$cookie =~ s/SESSION_ID=(\w*)/$1/;
#create a session object based on the cookie we got from the browser,
#or a new session if we got no cookie
my %session;
tie %session, 'Apache::Session::MySQL', $cookie, {
DataSource => 'dbi:mysql:sessions', #these arguments are
UserName => 'mySQL_user', #required when using
Password => 'password', #MySQL.pm
LockDataSource => 'dbi:mysql:sessions',
LockUserName => 'mySQL_user',
LockPassword => 'password'
};
#Might be a new session, so lets give them their cookie back
my $session_cookie = "SESSION_ID=$session{_session_id};";
$r->header_out("Set-Cookie" => $session_cookie);
#program continues...
=head1 SEE ALSO
Apache::Session::MySQL, Apache::Session::Postgres, Apache::Session::File,
Apache::Session::DB_File, Apache::Session::Oracle, Apache::Session::Sybase
The O Reilly book "Apache Modules in Perl and C", by Doug MacEachern and
Lincoln Stein, has a chapter on keeping state.
lib/Apache/Session/Generate/ModUsertrack.pm view on Meta::CPAN
package Apache::Session::Generate::ModUsertrack;
use strict;
use vars qw($VERSION);
$VERSION = '0.02';
use CGI::Cookie;
use constant MOD_PERL => exists $ENV{MOD_PERL};
sub generate {
my $session = shift;
my $name = $session->{args}->{ModUsertrackCookieName} || 'Apache';
my %cookies = CGI::Cookie->fetch;
if (!exists $cookies{$name} && MOD_PERL) {
# no cookies, try to steal from notes
require Apache;
my $r = Apache->request;
%cookies = CGI::Cookie->parse($r->notes('cookie'));
}
unless ($cookies{$name}) {
# still bad luck
require Carp;
Carp::croak('no cookie found. Make sure mod_usertrack is enabled.');
}
$session->{data}->{_session_id} = $cookies{$name}->value;
}
lib/Apache/Session/Generate/ModUsertrack.pm view on Meta::CPAN
=head1 SYNOPSIS
use Apache::Session::Flex;
tie %session, 'Apache::Session::Flex', $id, {
Store => 'MySQL',
Lock => 'Null',
Generate => 'ModUsertrack',
Serialize => 'Storable',
ModUsertrackCookieName => 'usertrack', # optional
};
=head1 DESCRIPTION
Apache::Session::Generate::ModUsertrack enables you to use cookie
tracked by mod_usertrack as session id for Apache::Session
framework. This module fits well with long-term sessions, so better
using RDBMS like MySQL for its storage.
=head1 CONFIGURATION
This module accepts one extra configuration option.
=over 4
=item ModUsertrackCookieName
Specifies cookie name used in mod_usertrack. C<Apache> for default, so
change this if you change it via C<CookieName> directive in
mod_usertrack.
=back
=head1 LIMITATION WITHOUT MOD_PERL
This module first tries to fetch named cookie, but will in vain B<ONLY
WHEN> the HTTP request is the first one from specific client to the
mod_usertrack enabled Apache web server. It is because if the request
is for the first time, cookies are not yet baked on clients.
( run in 0.329 second using v1.01-cache-2.11-cpan-4e96b696675 )