Apache-Voodoo

 view release on metacpan or  search on metacpan

lib/Apache/Voodoo/Engine.pm  view on Meta::CPAN

sub begin_run {
	my $self = shift;

	$self->{'mp'}->register_cleanup($self,\&finish);

	# setup debugging
	$debug = $self->_app->{'debug_handler'};
	$debug->init($self->{'mp'});
	$debug->mark(Time::HiRes::time,"START");

	$self->{'dbh'} = $self->attach_db();

	$self->{'session_handler'} = $self->attach_session();
	$self->{'session'} = $self->{'session_handler'}->session;

	$debug->session_id($self->{'session_handler'}->{'id'});
	$debug->mark(Time::HiRes::time,'Session Attachment');


	$debug->mark(Time::HiRes::time,'DB Connect');

	return 1;
}

sub attach_db {
	my $self = shift;

	my $db = undef;
	foreach (@{$self->_app->databases}) {
		eval {
			$db = DBI->connect_cached(@{$_});
		};
		last if $db;

		Apache::Voodoo::Exception::DBIConnect->throw($DBI::errstr);

lib/Apache/Voodoo/Engine.pm  view on Meta::CPAN

	delete $self->{'session'};
	delete $self->{'p'};
	delete $self->{'dbh'};

	if (defined($debug)) {
		$debug->mark(Time::HiRes::time,'END');
		$debug->shutdown();
	}
}

sub attach_session {
	my $self = shift;

	my $conf = $self->_app->config;

	my $session_id = $self->{'mp'}->get_cookie($conf->{'cookie_name'});

	my $session = $self->_app->{'session_handler'}->attach($session_id,$self->{'dbh'});

	if (!defined($session_id) || $session->id() ne $session_id) {
		# This is a new session, or there was an old cookie from a previous sesion,
		$self->{'mp'}->set_cookie($conf->{'cookie_name'},$session->id());
	}
	elsif ($session->has_expired($conf->{'session_timeout'})) {
		# the session has expired
		$self->{'mp'}->set_cookie($conf->{'cookie_name'},'!','now');
		$session->destroy;

lib/Apache/Voodoo/Session/File.pm  view on Meta::CPAN


	my $self = {};

	bless $self,$class;

	$self->{session_dir} = $conf->{'session_dir'};

	return $self;
}

sub attach {
	my $self = shift;
	my $id   = shift;
	my $dbh  = shift;

	my %opts = @_;

	my %session;
	my $obj;

	$opts{'Directory'}     = $self->{'session_dir'};

lib/Apache/Voodoo/Session/MySQL.pm  view on Meta::CPAN


	my $self = {};

	bless $self,$class;

	$self->{session_table} = $conf->{'session_table'};

	return $self;
}

sub attach {
	my $self = shift;
	my $id   = shift;
	my $dbh  = shift;

	my %opts = @_;

	my %session;
	my $obj;

	$opts{'TableName'}  = $self->{'session_table'};



( run in 0.582 second using v1.01-cache-2.11-cpan-e1769b4cff6 )