package Catalyst::Plugin::Session::State::Stash;
-use base qw/Catalyst::Plugin::Session::State Class::Accessor::Fast/;
-
-#Need to look up which version of perl is required.
-#use 5.008;
-use strict;
-use warnings;
+use Moose;
+use 5.008;
use MRO::Compat;
+use namespace::autoclean;
+
+extends 'Catalyst::Plugin::Session::State';
-our $VERSION = "0.10";
+our $VERSION = "0.12";
-BEGIN { __PACKAGE__->mk_accessors(qw/_deleted_session_id _prepared/) }
+has _deleted_session_id => ( is => 'rw' );
+has _prepared => ( is => 'rw' );
sub _stash_key_components {
my ($c) = @_;
- my $config = $c->config->{'Plugin::Session'} || $c->config->{'session'};
+ my $config = $c->_session_plugin_config;
return ($config->{stash_delim}) ?
split $config->{stash_delim}, $config->{stash_key} :
$config->{stash_key};
sub _set_session {
my ( $c,$key,$value) = @_;
-
$c->_get_session->{$key} = $value;
}
sub setup_session {
my $c = shift;
-
- $c->config->{'Plugin::Session'}
- and return $c->config->{'Plugin::Session'}->{stash_key} |= '_session';
- $c->config->{'session'}->{stash_key}
- ||= '_session';
+ $c->_session_plugin_config->{stash_key} ||= '_session';
}
sub prepare_action {
sub set_session_expires {
my ( $c, $expires ) = @_;
-
$c->_set_session(expires => time() + $expires);
$c->maybe::next::method($expires)
}
and key of '123/456' will store it as $c->stash->{123}->{456}
=item expires
-
+
How long the session should last in seconds.
=back
Manual work may be involved to make better use of this.
If you are writing a stateful web service with
-L<Catalyst::Plugin::Server::XMLRPC>, you will probably only have to deal with
+L<Catalyst::Plugin::Server::XMLRPC>, you will probably only have to deal with
loading, as when saving, the ID will already be on the stash.
=head1 SEE ALSO
=cut
-1;