use overload ();
use Object::Signature ();
-our $VERSION = "0.04";
+our $VERSION = "0.05";
my @session_data_accessors; # used in delete_session
BEGIN {
my $c = shift;
if ( my $sid = $c->_sessionid ) {
- my $flash_data = $c->_flash || {};
+ if ( my $flash_data = $c->_flash ) {
+ delete @{$flash_data}{ @{ $c->_flash_stale_keys || [] } };
- delete @{$flash_data}{ @{ $c->_flash_stale_keys || [] } };
-
- if (%$flash_data) { # damn 'my' declarations
- $c->store_session_data( "flash:$sid", $flash_data );
- }
- else {
- $c->delete_session_data("flash:$sid");
+ if (%$flash_data) {
+ $c->store_session_data( "flash:$sid", $flash_data );
+ }
+ else {
+ $c->delete_session_data("flash:$sid");
+ }
}
}
}
my $c = shift;
if (@_) {
+ if($c->_sessionid()) {
+ $c->log->warn('Session ID already set, ignoring.');
+ return $c->_sessionid();
+ }
if ( $c->validate_session_id( my $sid = shift ) ) {
$c->_sessionid($sid);
return unless defined wantarray;
=item flash
This is like Ruby on Rails' flash data structure. Think of it as a stash that
-lasts a single redirect, not only a forward.
+lasts for longer than one request, letting you redirect instead of forward.
+
+The flash data will be cleaned up only on requests on which actually use
+$c->flash (thus allowing multiple redirections), and the policy is to delete
+all the keys which were present at the time the data was loaded just before the
+data is saved.
sub moose : Local {
my ( $self, $c ) = @_;