Apache-ASP
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
my $checksum = &md5_hex($key).'x'.length($key);
my $metakey = $checksum . 'xMETA';
my $rv;
eval {
$cache_dbm->{dbm}->Lock;
if(defined $value) {
my $meta = { ServerID => $ServerID, Creation => time() };
if(defined $expires && ($expires =~ /^\-?\d+$/)) {
$meta->{Expires} = $expires;
$meta->{Timeout} = time + $expires;
};
$self->{dbg} && $self->Debug("storing $checksum in $cache_name cache");
$cache_dbm->STORE($metakey, $meta);
$self->{cache_count_store}++;
$rv = $cache_dbm->STORE($checksum, $value);
} else {
# don't check meta data for XSLT since transformations don't expire ever
if($no_check_meta) {
$self->{dbg} && $self->Debug("cache $cache_name fetch checksum $checksum no check meta");
$self->{cache_count_fetch}++;
lib/Apache/ASP/Session.pm view on Meta::CPAN
my($self, $index) = @_;
# putting these comparisons in a regexp was a little
# slower than keeping them in these 'eq' statements
if($index eq '_SELF') {
$self;
} elsif($index eq '_STATE') {
$self->{state};
} elsif($index eq 'SessionID') {
$self->{id};
} elsif($index eq 'Timeout') {
$self->Timeout();
} else {
$self->{state}->FETCH($index);
}
}
sub STORE {
my($self, $index, $value) = @_;
if($index eq 'Timeout') {
$self->Timeout($value);
} else {
$self->{state}->STORE($index, $value);
}
}
# firstkey and nextkey skip the _UA key so the user
# we need to keep the ua info in the session db itself,
# so we are not dependent on writes going through to Internal
# for this very critical informatioh. _UA is used for security
# validation / the user's user agent.
lib/Apache/ASP/StateManager.pm view on Meta::CPAN
package Apache::ASP;
# quickly decomped out of Apache::ASP so we could load the routines only
# when we are managing State objects
use Apache::ASP::State;
use strict;
use vars qw(
$CleanupGroups
$SessionIDLength $SessionTimeout $StateManager
$DefaultStateDB $DefaultStateSerializer
);
$SessionTimeout = 20;
$StateManager = 10;
# Some OS's have hashed directory lookups up to 16 bytes, so we leave room
# for .lock extension ... nevermind, security is more important, back to 32
# $SessionIDLength = 11;
$SessionIDLength = 32;
$DefaultStateDB = 'SDBM_File';
$DefaultStateSerializer = 'Data::Dumper';
sub InitState {
site/apps/bookmarks/.htaccess view on Meta::CPAN
DirectoryIndex index.asp
<Files ~ \.asp$>
SetHandler perl-script
PerlHandler Apache::ASP
PerlSetVar Global .
PerlSetVar GlobalPackage My::Bookmarks
PerlSetVar StateDir /tmp/asp_apps_bookmarks
PerlSetVar Debug 2
PerlSetVar SessionTimeout 15
PerlSetVar StatScripts On
PerlSetVar AllowApplicationState On
PerlSetVar AllowSessionState On
PerlSetVar TimeHiRes On
</Files>
site/articles/perlmonth1_intro.html view on Meta::CPAN
set of objects and events, my favorite being $Session, which was one of ASP's
key selling points for me. $Session is ASP's answer to the problem of HTTP being a
stateless protocol. By using temporary session cookies, each web user
has a unique $Session in which you may store data, and that follows them from
script to script. Because the data storage
for $Session is handled on the server, you do not have to worry about
size limits of cookies as an alternate mechanism of storing user session data.
<p>
There are some very useful events as well. Let's say that you are
using <tt>$Session->{login}</tt> to control a user account login and logout. Because
$Session automatically times out every SessionTimeout, if a user
walks away from her/his computer for SessionTimeout minutes, the
<tt>$Session->{login}</tt> is destroyed along with the rest of the data stored in
$Session, and the next person that uses the computer will find themselves
automatically logged out from the account. This is a huge security win if
you maintain a set of accounts at your web site that hold sensitive information like
credit card numbers.
<p>
Here is a basic listing of the built-in <a href=http://www.apache-asp.org/objects.html>objects</a>
available to the developer within every <a href=http://www.apache-asp.org>Apache::ASP</a>
script:
<pre>
site/articles/perlmonth2_build.html view on Meta::CPAN
first user's bookmarks.
<p>
<h3>Specification</h3>
Often times, there is a specification round that we
must do to pick our web application environment and
hardware, as well as supported client software, but this is a no
brainer here. We are choosing Apache::ASP because of its built
in <tt>$Session</tt> which make user logins easy, and its built
in event <tt>Session_OnEnd</tt> which will automatically destroy
the contents of <tt>$Session</tt> every <tt>SessionTimeout</tt>, which
defaults to 20 minutes.
<p>
Also, because our web application has more than one page, we
will make use of the same headers and footers for each
page, using the includes <tt><!--#include file=src.inc--></tt>
functionality to modularize the html.
<h3>Design</h3>
Before we start coding, let's take a minute to diagram
what pages and actions our MyBookmarks web application
site/eg/.htaccess view on Meta::CPAN
PerlSetVar CompressGzip 0
PerlSetVar UseStrict 1
#PerlSetVar CacheDB DB_File
PerlSetVar CacheDB MLDBM::Sync::SDBM_File
# .asp files for Session state enabled
<Files ~ (\.asp)>
SetHandler perl-script
PerlHandler Apache::ASP
PerlSetVar CookiePath /
PerlSetVar SessionTimeout 5
PerlSetVar RegisterIncludes 1
PerlSetVar XMLSubsMatch my:\w+
PerlSetVar AllowApplicationState 1
PerlSetVar AllowSessionState 1
# PerlSetVar StateSerializer Storable
# PerlSetVar StateDB DB_File
# PerlSetVar StatScripts 0
</Files>
# .htm files for the ASP parsing, but not the $Session object
site/events.html view on Meta::CPAN
<font face="courier new" size=3><pre>
</pre></font>Triggered by a user session ending, Session_OnEnd can be useful
for cleaning up and analyzing user data accumulated during a session.
<font face="courier new" size=3><pre>
</pre></font>Sessions end when the session timeout expires, and the StateManager
performs session cleanup. The timing of the Session_OnEnd does not
occur immediately after the session times out, but when the first
script runs after the session expires, and the StateManager allows
for that session to be cleaned up.
<font face="courier new" size=3><pre>
</pre></font>So on a busy site with default SessionTimeout (20 minutes) and
StateManager (10 times) settings, the Session_OnEnd for a particular
session should be run near 22 minutes past the last activity that Session saw.
A site infrequently visited will only have the Session_OnEnd run
when a subsequent visit occurs, and theoretically the last session
of an application ever run will never have its Session_OnEnd run.
<font face="courier new" size=3><pre>
</pre></font>Thus I would not put anything mission-critical in the Session_OnEnd,
just stuff that would be nice to run whenever it gets run.</font>
<p>
site/objects.html view on Meta::CPAN
<a href=#%24Request-%3E%7BM81641f4a>$Request->{Method}</a>
</font>
</td>
</tr>
<tr>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#%24Session-%3E%7BTf539b225>$Session->{Timeout} [= $minutes]</a>
</font>
</td>
<td valign=top >
<font face="lucida console" size=-1>
<a href=#%24Request-%3E%7BT6acbcf5a>$Request->{TotalBytes}</a>
</font>
</td>
</tr>
t/session_events.t view on Meta::CPAN
$0 =~ /^(.*)$/;
$0 = $1;
chdir(dirname($0));
$0 = basename($0);
my $t = T->new();
my %config = (
'NoState' => 0,
'SessionTimeout' => 20,
'Debug' => 0,
'SessionCount' => 1,
'Global' => 'session_events',
'SessionQuery' => 1,
);
my $r = Apache::ASP::CGI->init($0);
map { $r->dir_config->set($_, $config{$_}) } keys %config;
my $ASP = Apache::ASP->new($r);
view all matches for this distributionview release on metacpan - search on metacpan
( run in 2.400 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )