4 use Plack::Session::State;
5 use Plack::Session::State::Cookie;
6 use Plack::Session::Store;
7 use Plack::Middleware::Session;
9 my $app = Plack::Middleware::Session->wrap(
12 my $r = Plack::Request->new( $env );
14 return [ 404, [], [] ] if $r->path_info =~ /favicon.ico/;
16 my $session = $r->session;
18 my $id = $session->id;
19 my $counter = $session->get('counter') || 0;
21 $session->set( 'counter' => $counter + 1 );
25 if ( $r->param( 'logout' ) ) {
27 $resp = $r->new_response;
28 $resp->redirect( $r->path_info );
31 $resp = $r->new_response(
33 [ 'Content-Type' => 'text/html' ],
38 <title>Plack::Middleware::Session Example</title>
41 <h1>Session Id: ${id}</h1>
42 <h2>Counter: ${counter}</h2>
44 <a href="/?logout=1">Logout</a>
54 state => Plack::Session::State::Cookie->new,
55 store => Plack::Session::Store->new,