1 package Plack::Session::State::Cookie;
6 our $AUTHORITY = 'cpan:STEVAN';
8 use parent 'Plack::Session::State';
10 use Plack::Util::Accessor qw[
17 sub expire_session_id {
19 $self->SUPER::expire_session_id( $id );
23 sub get_session_id_from_request {
24 my ($self, $request) = @_;
25 ( $request->cookie( $self->session_key ) || return )->value;
29 my ($self, $id, $response) = @_;
30 $response->cookies->{ $self->session_key } = +{
32 path => ($self->path || '/'),
33 ( defined $self->domain ? ( domain => $self->domain ) : () ),
34 ( defined $self->expires ? ( expires => $self->expires ) : () ),
35 ( defined $self->secure ? ( secure => $self->secure ) : () ),
38 # clear the expires after
39 # finalization if the session
40 # has been expired - SL
41 $self->expires( undef )
42 if defined $self->expires
43 && $self->expires == 0
44 && $self->is_session_expired( $id );
55 Plack::Session::State::Cookie - Basic cookie-based session state
60 use Plack::Middleware::Session;
63 return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Foo' ] ];
67 enable 'Session'; # Cookie is the default state
73 This is a subclass of L<Plack::Session::State> and implements it's
74 full interface. This is the default state used in
75 L<Plack::Middleware::Session>.
81 =item B<new ( %params )>
83 The C<%params> can include I<path>, I<domain>, I<expires> and
84 I<secure> options, as well as all the options accepted by
85 L<Plack::Session::Store>.
89 Path of the cookie, this defaults to "/";
93 Domain of the cookie, if nothing is supplied then it will not
94 be included in the cookie.
98 Expiration time of the cookie, if nothing is supplied then it will
99 not be included in the cookie.
103 Secure flag for the cookie, if nothing is supplied then it will not
104 be included in the cookie.
110 All complex software has bugs lurking in it, and this module is no
111 exception. If you find a bug please either email me, or add the bug
116 Stevan Little E<lt>stevan.little@iinteractive.comE<gt>
118 =head1 COPYRIGHT AND LICENSE
120 Copyright 2009 Infinity Interactive, Inc.
122 L<http://www.iinteractive.com>
124 This library is free software; you can redistribute it and/or modify
125 it under the same terms as Perl itself.