1 package Plack::Middleware::Session;
8 use Plack::Session::State::Cookie;
9 use Plack::Session::Store;
11 use parent 'Plack::Middleware';
13 use Plack::Util::Accessor qw( state store );
17 unless ($self->state) {
18 $self->state( Plack::Session::State::Cookie->new );
21 unless ($self->store) {
22 $self->store( Plack::Session::Store->new );
30 $env->{'plack.session'} = Plack::Session->new(
31 state => $self->state,
32 store => $self->store,
33 request => Plack::Request->new( $env )
36 my $res = $self->app->($env);
37 $self->response_cb($res, sub {
38 my $res = Plack::Response->new(@{$_[0]});
39 $env->{'plack.session'}->finalize( $res );
40 @{$_[0]} = @{$res->finalize};
52 Plack::Middleware::Session - Middleware for session management
56 use Plack::Middleware::Session;
62 All complex software has bugs lurking in it, and this module is no
63 exception. If you find a bug please either email me, or add the bug
70 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
72 =head1 COPYRIGHT AND LICENSE
74 Copyright 2009 Infinity Interactive, Inc.
76 L<http://www.iinteractive.com>
78 This library is free software; you can redistribute it and/or modify
79 it under the same terms as Perl itself.