1 package Catalyst::Plugin::Session::State::Cookie;
2 use base qw/Catalyst::Plugin::Session::State/;
12 if ( my $sid = $c->sessionid ) {
13 my $cookie = $c->request->cookies->{session};
14 if ( !$cookie or $cookie->value ne $sid ) {
15 $c->response->cookies->{session} = { value => $sid };
16 $c->log->debug(qq/A cookie with the session id "$sid" was saved/)
21 return $c->NEXT::finalize(@_);
27 if ( my $cookie = $c->request->cookies->{session} ) {
28 my $sid = $cookie->value;
30 $c->log->debug(qq/Found sessionid "$sid" in cookie/) if $c->debug;
33 $c->NEXT::prepare_cookies(@_);
44 Catalyst::Plugin::Session::State::Cookie - A session ID
48 use Catalyst qw/Session Session::State::Cookie Session::Store::Foo/;
52 In order for L<Catalyst::Plugin::Session> to work the session ID needs to be
53 stored on the client, and the session data needs to be stored on the server.
55 This plugin stores the session ID on the client using the cookie mechanism.
57 =head1 EXTENDED METHODS
63 Will restore if an appropriate cookie is found.
67 Will set a cookie called C<session> if it doesn't exist or if it's value is not the current session id.
73 L<Catalyst>, L<Catalyst::Plugin::Session>.
77 Sebastian Riedel E<lt>C<sri@cpan.org>E<gt>,
78 Marcus Ramberg E<lt>C<mramberg@cpan.org>E<gt>,
79 Andrew Ford E<lt>C<andrewf@cpan.org>E<gt>,
80 Yuval Kogman E<lt>C<nothingmuch@woobling.org>E<gt>
84 This program is free software, you can redistribute it and/or modify it
85 under the same terms as Perl itself.