App-Context
view release on metacpan or search on metacpan
lib/App/Serializer/OneLine.pm
lib/App/Serializer/Perl.pm
lib/App/Serializer/Properties.pm
lib/App/Serializer/Scalar.pm
lib/App/Serializer/Storable.pm
lib/App/Serializer/TextArray.pm
lib/App/Serializer/Xml.pm
lib/App/Serializer/Yaml.pm
lib/App/Service.pm
lib/App/Session.pm
lib/App/Session/Cookie.pm
lib/App/Session/HTMLHidden.pm
lib/App/SessionObject.pm
lib/App/SharedDatastore.pm
lib/App/UserAgent.pm
lib/App/ValueDomain.pm
Makefile.PL
MANIFEST
README
t/app.ini
t/app.pl
lib/App/Session.pm view on Meta::CPAN
=head1 Class Group: Session
The following classes might be a part of the Session Class Group.
=over
=item * Class: App::Session
=item * Class: App::Session::HTMLHidden
=item * Class: App::Session::Cookie
=item * Class: App::Session::ApacheSession
=item * Class: App::Session::ApacheSessionX
=back
=cut
#############################################################################
lib/App/Session/Cookie.pm view on Meta::CPAN
#############################################################################
## $Id: Cookie.pm 3666 2006-03-11 20:34:10Z spadkins $
#############################################################################
package App::Session::Cookie;
$VERSION = (q$Revision: 3666 $ =~ /(\d[\d\.]*)/)[0]; # VERSION numbers generated by svn
use App;
use App::Session;
@ISA = ( "App::Session" );
use strict;
use Data::Dumper;
use Storable qw(freeze thaw);
lib/App/Session/Cookie.pm view on Meta::CPAN
# note: We may want to apply an HMAC (hashed message authentication code)
# so that users cannot fiddle with the values.
# We may also want to add IP address and timeout for security.
# We may also want to add encryption so they can't even decode the data.
# use Digest::HMAC_MD5;
# use Crypt::CBC;
=head1 NAME
App::Session::Cookie - a session whose state is maintained across
HTML requests by being embedded in an HTTP cookie.
=head1 SYNOPSIS
# ... official way to get a Session object ...
use App;
$session = App->session();
$session = $session->session(); # get the session
# any of the following named parameters may be specified
$session = $session->session(
);
# ... alternative way (used internally) ...
use App::Session::Cookie;
$session = App::Session->new();
=cut
#############################################################################
# CONSTANTS
#############################################################################
=head1 DESCRIPTION
A Session class models the sequence of events associated with a
use of the system. These events may occur in different processes.
Yet the accumulated state of the session needs to be propagated from
one process to the next.
This Session::Cookie maintains its state across
HTML requests by being embedded in an HTTP cookie.
As a result, it requires no server-side storage, so the sessions
never need to time out.
The Session::Cookie has an advantage over Session::HTMLHidden in that
data does not need to be posted to a URL for the session data to be
transmitted to it. This allows that the state can be propagated
properly to sub-components of an HTML page such as
* frame documents within a frameset (<frame src=...>)
* dynamically generated images (<img src=...>, <input type=image src=...>)
Limits on cookie storage are as follows, according to "Dynamic HTML,
The Definitive Reference" by O'Reilly in the DOM Reference under
"document.cookie".
* max 2000 chars per cookie (recommended, although 4000 supposedly allowed)
* max 20 cookies per domain
This allows for roughly 40K of session storage.
It is quite conceivable that this amount of storage could be overrun,
so Session::Cookie is only appropriate in situations where you are confident
it will not be. Also, session_objects should take care to clean up after themselves,
and static values stored in the session can alternatively be provided in
the config.
=cut
#############################################################################
# CONSTRUCTOR METHODS
#############################################################################
lib/App/Session/Cookie.pm view on Meta::CPAN
# length of a MIME/Base64 line is (76 chars + newline)
# the max length of a cookie should be 2000 chars (although the Netscape spec is 4k per cookie)
$maxvarlines = 25;
$maxvarsize = $maxvarlines*77; # 1925 chars
$headers = "";
$cookieoptions = ""; # TODO: expires, path, domain, secure
$html = "";
if (length($sessiontext) <= $maxvarsize) {
$sessiontext =~ s/\n//g; # get rid of newlines (76 char lines)
$headers = "Set-Cookie: app_sessiondata=$sessiontext$cookieoptions\n";
$self->{context}->set_header($headers);
}
else {
my (@sessiontext, $i, $startidx, $endidx, $textchunk);
@sessiontext = split(/\n/,$sessiontext);
$i = 1;
$startidx = 0;
$endidx = $startidx+$maxvarlines-1;
$textchunk = join("",@sessiontext[$startidx .. $endidx]);
$headers .= "Set-Cookie: app_sessiondata=$textchunk$cookieoptions\n";
while ($endidx < $#sessiontext) {
$i++;
$startidx += $maxvarlines;
$endidx = $startidx+$maxvarlines-1;
$endidx = $#sessiontext if ($endidx > $#sessiontext-1);
$textchunk = join("",@sessiontext[$startidx .. $endidx]);
$headers .= "Set-Cookie: app_sessiondata${i}=$textchunk$cookieoptions\n";
}
$self->{context}->set_header($headers);
}
if ($options && $options->{show_session}) {
# Debugging Only
my $d = Data::Dumper->new([ $sessiondata ], [ "sessiondata" ]);
$d->Indent(1);
$html .= "<!-- Contents of the session. (For debugging only. Should be turned off in production.)\n";
$html .= $sessiontemp;
lib/App/Session/Cookie.pm view on Meta::CPAN
$i++;
}
$sessiontext =~ s/ /\+/g;
$length = length($sessiontext);
$pad = 4 - ($length % 4);
$pad = 0 if ($pad == 4);
$sessiontext .= ("=" x $pad) if ($pad);
#print "length(sessiontext)=", length($sessiontext), "\n";
$sessiontext =~ s/(.{76})/$1\n/g;
$sessiontext .= "\n";
#print "Session::Cookie->_init(): sessiontext = [\n$sessiontext\n]\n";
$store = thaw(Compress::Zlib::memGunzip(MIME::Base64::decode($sessiontext)));
}
}
$self->{context} = $args->{context} if (defined $args->{context});
$self->{store} = $store;
$self->{cache} = {};
}
1;
lib/App/Session/HTMLHidden.pm view on Meta::CPAN
$sessiondata->{SessionObject}{default}{$cookie_attrib};
}
}
my $cgi = $self->{context}->request()->{cgi};
my $secure = ($cgi->url() =~ /^https/) ? "; secure" : "";
my $cookietext = MIME::Base64::encode(Compress::Zlib::memGzip(freeze($cookiedata)));
$cookietext =~ s/\n//g; # get rid of newlines (76 char lines)
my $cookie_options = $options->{"app.Session.cookie_options"} || "$secure";
my $headers = "Set-Cookie: app_session_${app}_persist=$cookietext$cookie_options\n";
$self->{context}->set_header($headers);
}
&App::sub_exit($html) if ($App::trace);
$html;
}
#############################################################################
# PROTECTED METHODS
#############################################################################
lib/App/Session/HTMLHidden.pm view on Meta::CPAN
my $app = $options->{"app"};
my $cookietext = $cgi->cookie("app_session_${app}_persist");
if ($cookietext) {
$cookietext =~ s/ /\+/g;
my $length = length($cookietext);
my $pad = 4 - ($length % 4);
$pad = 0 if ($pad == 4);
$cookietext .= ("=" x $pad) if ($pad);
$cookietext =~ s/(.{76})/$1\n/g;
$cookietext .= "\n";
#print "Session::Cookie->_init(): sessiontext = [\n$sessiontext\n]\n";
$cookiedata = thaw(Compress::Zlib::memGunzip(MIME::Base64::decode($cookietext)));
}
foreach my $cookie_attrib (split(/[ ,;]+/, $cookie_attribs)) {
if ($cookie_attrib =~ /^([^-]+)-(.+)$/) {
$store->{SessionObject}{$1}{$2} = $cookiedata->{$1}{$2};
}
elsif ($cookie_attrib) {
$store->{SessionObject}{default}{$cookie_attrib} =
$cookiedata->{default}{$cookie_attrib};
lib/App/quickstart.pod view on Meta::CPAN
=item * L<App::Request>
=item * +-- L<App::Request::CGI>
=item * L<App::Response>
=item * L<App::Session>
=item * +-- L<App::Session::HTMLHidden>
=item * +-- L<App::Session::Cookie>
=item * L<App::Reference>
=item * +-- L<App::Conf>
=item * =====+-- L<App::Conf::File>
=item * L<App::Service>
=item * +-- L<App::Serializer>
( run in 0.419 second using v1.01-cache-2.11-cpan-e9199f4ba4c )