| Dancer documentation | Contained in the Dancer distribution. |
Dancer::Session::Simple - in-memory session backend for Dancer
This module implements a very simple session backend, holding all session data in memory. This means that sessions are volatile, and no longer exist when the process exits. This module is likely to be most useful for testing purposes.
The setting session should be set to Simple in order to use this session
engine in a Dancer application.
This module has been written by David Precious, see the AUTHORS file for details.
See Dancer::Session for details about session usage in route handlers.
This module is copyright (c) 2010 David Precious <davidp@preshweb.co.uk>
This module is free software and is released under the same terms as Perl itself.
| Dancer documentation | Contained in the Dancer distribution. |
package Dancer::Session::Simple; use strict; use warnings; use base 'Dancer::Session::Abstract'; use Dancer::ModuleLoader; use Dancer::Config 'setting'; use Dancer::FileUtils 'path'; my %sessions; # create a new session and return the newborn object # representing that session sub create { my ($class) = @_; my $self = Dancer::Session::Simple->new; $self->flush; return $self; } # Return the session object corresponding to the given id sub retrieve { my ($class, $id) = @_; return $sessions{$id}; } sub destroy { my ($self) = @_; undef $sessions{$self->id}; } sub flush { my $self = shift; $sessions{$self->id} = $self; return $self; } 1; __END__