=head1 SYNOPSIS
- use Catalyst qw/Session Session::Store::FastMmap Session::State::Cookie/;
+ # To get sessions to "just work", all you need to do is use these plugins:
+
+ use Catalyst qw/
+ Session
+ Session::Store::FastMmap
+ Session::State::Cookie
+ /;
+
+ # you can replace Store::FastMmap with Store::File - both have sensible
+ # default configurations (see their docs for details)
+
+ # more complicated backends are available for other scenarios (DBI storage,
+ # etc)
+
+
+ # after you've loaded the plugins you can save session data
+ # For example, if you are writing a shopping cart, it could be implemented
+ # like this:
sub add_item : Local {
my ( $self, $c ) = @_;
my $item_id = $c->req->param("item");
- # $c->session is stored across requests, so
- # other actions will see these values
+ # $c->session is a hash ref, a bit like $c->stash
+ # the difference is that it' preserved across requests
push @{ $c->session->{items} }, $item_id;
# values in $c->session are restored
$c->stash->{items_to_display} =
- [ map { MyModel->retrieve($_) } @{ $c->session->{items} } ];
+ [ map { MyModel->retrieve($_) } @{ $c->session->{items} } ];
$c->forward("MyView");
}
This plugin links the two pieces together.
+=head1 RECCOMENDED BACKENDS
+
+=over 4
+
+=item Session::State::Cookie
+
+The only really sane way to do state is using cookies.
+
+=item Session::Store::File
+
+A portable backend, based on Cache::File.
+
+=item Session::Store::FastMmap
+
+A fast and flexible backend, based on Cache::FastMmap.
+
+=back
+
=head1 METHODS
=over 4
=back
+=back
+
+=item INTERNAL METHODS
+
+=over 4
+
=item setup
This method is extended to also make calls to
=head1 AUTHORS
-
+Andy Grundman
+Christian Hansen
+Yuval Kogman, C<nothingmuch@woobling.org>
+Sebastian Riedel
=head1 COPYRIGHT & LICNESE