use Digest ();
use overload ();
use Object::Signature ();
+use Carp;
-our $VERSION = "0.12";
+our $VERSION = "0.19";
my @session_data_accessors; # used in delete_session
BEGIN {
%$cfg = (
expires => 7200,
- verify_address => 1,
+ verify_address => 0,
%$cfg,
);
$c->NEXT::prepare_action(@_);
}
+sub finalize_headers {
+ my $c = shift;
+
+ # fix cookie before we send headers
+ $c->_save_session_expires;
+
+ return $c->NEXT::finalize_headers(@_);
+}
+
sub finalize {
my $c = shift;
+ my $ret = $c->NEXT::finalize(@_);
+ # then finish the rest
$c->finalize_session;
-
- $c->NEXT::finalize(@_);
+ return $ret;
}
sub finalize_session {
$c->_save_session_id;
$c->_save_session;
$c->_save_flash;
- $c->_save_session_expires;
$c->_clear_session_instance_data;
}
(@{$href}{@keys}) = ((undef) x @keys);
}
-sub flash {
+sub _flash_data {
my $c = shift;
$c->_flash || $c->_load_flash || do {
$c->create_session_id_if_needed;
$c->_flash( {} );
+ };
+}
+
+sub _set_flash {
+ my $c = shift;
+ if (@_) {
+ my $items = @_ > 1 ? {@_} : $_[0];
+ croak('flash takes a hash or hashref') unless ref $items;
+ @{ $c->_flash }{ keys %$items } = values %$items;
}
}
+sub flash {
+ my $c = shift;
+ $c->_flash_data;
+ $c->_set_flash(@_);
+ return $c->_flash;
+}
+
sub clear_flash {
my $c = shift;
+
+ #$c->delete_session_data("flash:" . $c->sessionid); # should this be in here? or delayed till finalization?
$c->_flash_key_hashes({});
+ $c->_flash_keep_keys({});
$c->_flash({});
}
This plugin links the two pieces together.
-=head1 RECCOMENDED BACKENDS
+=head1 RECOMENDED BACKENDS
=over 4
parameter is on - then it will copy the contents of the flash to the stash at
prepare time.
+=item finalize_headers
+
+This method is extended and will extend the expiry time before sending
+the response.
+
=item finalize
-This method is extended and will extend the expiry time, as well as persist the
-session data if a session exists.
+This method is extended and will call finalize_session after the other
+finalizes run. Here we persist the session data if a session exists.
=item initialize_session_data
See L<Catalyst/dump_these> - ammends the session data structure to the list of
dumped objects if session ID is defined.
+
+=item calculate_extended_session_expires
+
+=item calculate_initial_session_expires
+
+=item create_session_id_if_needed
+
+=item delete_session_id
+
+=item extend_session_expires
+
+=item extend_session_id
+
+=item get_session_id
+
+=item reset_session_expires
+
+=item session_is_valid
+
+=item set_session_id
+
=back
=head1 USING SESSIONS DURING PREPARE
When true, C<<$c->request->address>> will be checked at prepare time. If it is
not the same as the address that initiated the session, the session is deleted.
+Defaults to false.
+
=item flash_to_stash
This option makes it easier to have actions behave the same whether they were