1 package Plack::Session::State::Cookie;
5 use parent 'Plack::Session::State';
7 use Plack::Util::Accessor qw[
14 sub expire_session_id {
16 $self->SUPER::expire_session_id( $id );
20 sub get_request_session_id {
21 my ($self, $request ) = @_;
22 ($request->cookie( $self->session_key ) || return )->value;
26 my ($self, $request) = @_;
27 $self->check_expired( $self->get_request_session_id($request) || return );
31 my ($self, $id, $response) = @_;
32 $response->cookies->{ $self->session_key } = +{
34 path => ($self->path || '/'),
35 ( defined $self->domain ? ( domain => $self->domain ) : () ),
36 ( defined $self->expires ? ( expires => $self->expires ) : () ),
37 ( defined $self->secure ? ( secure => $self->secure ) : () ),
40 # clear the expires after
41 # finalization if the session
42 # has been expired - SL
43 $self->expires( undef )
44 if defined $self->expires
45 && $self->expires == 0
46 && $self->is_session_expired( $id );
57 Plack::Session::State::Cookie - Basic cookie-based session state
62 use Plack::Middleware::Session;
65 return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Foo' ] ];
69 enable 'Session'; # Cookie is the default state
75 This is a subclass of L<Plack::Session::State> and implements it's
76 full interface. This is the default state used in
77 L<Plack::Middleware::Session>.
83 =item B<new ( %params )>
85 The C<%params> can include I<path>, I<domain>, I<expires> and
86 I<secure> options, as well as all the options accepted by
87 L<Plack::Session::Store>.
91 Path of the cookie, this defaults to "/";
95 Domain of the cookie, if nothing is supplied then it will not
96 be included in the cookie.
100 Expiration time of the cookie, if nothing is supplied then it will
101 not be included in the cookie.
105 Secure flag for the cookie, if nothing is supplied then it will not
106 be included in the cookie.
112 All complex software has bugs lurking in it, and this module is no
113 exception. If you find a bug please either email me, or add the bug
118 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
120 =head1 COPYRIGHT AND LICENSE
122 Copyright 2009 Infinity Interactive, Inc.
124 L<http://www.iinteractive.com>
126 This library is free software; you can redistribute it and/or modify
127 it under the same terms as Perl itself.