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_session_id_from_request {
21 my ($self, $request) = @_;
22 ( $request->cookie( $self->session_key ) || return )->value;
26 my ($self, $id, $response) = @_;
27 $response->cookies->{ $self->session_key } = +{
29 path => ($self->path || '/'),
30 ( defined $self->domain ? ( domain => $self->domain ) : () ),
31 ( defined $self->expires ? ( expires => $self->expires ) : () ),
32 ( defined $self->secure ? ( secure => $self->secure ) : () ),
35 # clear the expires after
36 # finalization if the session
37 # has been expired - SL
38 $self->expires( undef )
39 if defined $self->expires
40 && $self->expires == 0
41 && $self->is_session_expired( $id );
52 Plack::Session::State::Cookie - Basic cookie-based session state
57 use Plack::Middleware::Session;
60 return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Foo' ] ];
64 enable 'Session'; # Cookie is the default state
70 This is a subclass of L<Plack::Session::State> and implements it's
71 full interface. This is the default state used in
72 L<Plack::Middleware::Session>.
78 =item B<new ( %params )>
80 The C<%params> can include I<path>, I<domain>, I<expires> and
81 I<secure> options, as well as all the options accepted by
82 L<Plack::Session::Store>.
86 Path of the cookie, this defaults to "/";
90 Domain of the cookie, if nothing is supplied then it will not
91 be included in the cookie.
95 Expiration time of the cookie, if nothing is supplied then it will
96 not be included in the cookie.
100 Secure flag for the cookie, if nothing is supplied then it will not
101 be included in the cookie.
107 All complex software has bugs lurking in it, and this module is no
108 exception. If you find a bug please either email me, or add the bug
113 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
115 =head1 COPYRIGHT AND LICENSE
117 Copyright 2009 Infinity Interactive, Inc.
119 L<http://www.iinteractive.com>
121 This library is free software; you can redistribute it and/or modify
122 it under the same terms as Perl itself.