various changes to C::P::Session, including clear_flash
[catagits/Catalyst-Plugin-Session.git] / lib / Catalyst / Plugin / Session.pm
index 29e4d82..887fb28 100644 (file)
@@ -99,14 +99,14 @@ sub finalize {
 sub finalize_session {
     my $c = shift;
 
+    $c->NEXT::finalize_session;
+
     $c->_save_session_id;
     $c->_save_session;
     $c->_save_flash;
     $c->_save_session_expires;
 
     $c->_clear_session_instance_data;
-
-    $c->NEXT::finalize_session;
 }
 
 sub _save_session_id {
@@ -261,7 +261,7 @@ sub _clear_session_instance_data {
 sub delete_session {
     my ( $c, $msg ) = @_;
 
-    $c->log->debug("Deleting session") if $c->debug;
+    $c->log->debug("Deleting session" . ( defined($msg) ? "($msg)" : '(no reason given)') ) if $c->debug;
 
     # delete the session data
     if ( my $sid = $c->sessionid ) {
@@ -388,6 +388,12 @@ sub flash {
     }
 }
 
+sub clear_flash {
+    my $c = shift;
+    $c->_flash_key_hashes({});
+    $c->_flash({});
+}
+
 sub session_expire_key {
     my ( $c, %keys ) = @_;
 
@@ -639,6 +645,10 @@ of every request.
         }
     }
 
+=item clear_flash
+
+Zap all the keys in the flash regardless of their current state.
+
 =item keep_flash @keys
 
 If you wawnt to keep a flash key for the next request too, even if it hasn't