switch to module::install
[catagits/Catalyst-Plugin-Session.git] / lib / Catalyst / Plugin / Session.pm
index 3bc631d..08ef366 100644 (file)
@@ -13,7 +13,7 @@ use overload            ();
 use Object::Signature   ();
 use Carp;
 
-our $VERSION = "0.18";
+our $VERSION = '0.20';
 
 my @session_data_accessors; # used in delete_session
 BEGIN {
@@ -92,11 +92,21 @@ sub prepare_action {
 sub finalize_headers {
     my $c = shift;
 
-    $c->finalize_session;
+    # 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;
+    return $ret;
+}
+
 sub finalize_session {
     my $c = shift;
 
@@ -105,7 +115,6 @@ sub finalize_session {
     $c->_save_session_id;
     $c->_save_session;
     $c->_save_flash;
-    $c->_save_session_expires;
 
     $c->_clear_session_instance_data;
 }
@@ -401,8 +410,8 @@ sub _set_flash {
 sub flash {
     my $c = shift;
     $c->_flash_data;
-       $c->_set_flash(@_);
-       return $c->_flash;
+    $c->_set_flash(@_);
+    return $c->_flash;
 }
 
 sub clear_flash {
@@ -521,8 +530,7 @@ __END__
 
 =head1 NAME
 
-Catalyst::Plugin::Session - Generic Session plugin - ties together server side
-storage and client side state required to maintain session data.
+Catalyst::Plugin::Session - Generic Session plugin - ties together server side storage and client side state required to maintain session data.
 
 =head1 SYNOPSIS
 
@@ -534,11 +542,11 @@ storage and client side state required to maintain session data.
       Session::State::Cookie
       /;
 
-       # you can replace Store::FastMmap with Store::File - both have sensible
-       # default configurations (see their docs for details)
+    # you can replace Store::FastMmap with Store::File - both have sensible
+    # default configurations (see their docs for details)
 
-       # more complicated backends are available for other scenarios (DBI storage,
-       # etc)
+    # more complicated backends are available for other scenarios (DBI storage,
+    # etc)
 
 
     # after you've loaded the plugins you can save session data
@@ -671,7 +679,7 @@ 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
+If you want to keep a flash key for the next request too, even if it hasn't
 changed, call C<keep_flash> and pass in the keys as arguments.
 
 =item delete_session REASON
@@ -745,8 +753,13 @@ prepare time.
 
 =item finalize_headers
 
-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 extend the expiry time before sending
+the response.
+
+=item finalize
+
+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
 
@@ -781,25 +794,15 @@ Currently it returns a concatenated string which contains:
 
 =over 4
 
-=item *
-
-A counter
-
-=item *
-
-The current time
-
-=item *
-
-One value from C<rand>.
+=item * A counter
 
-=item *
+=item * The current time
 
-The stringified value of a newly allocated hash reference
+=item * One value from C<rand>.
 
-=item *
+=item * The stringified value of a newly allocated hash reference
 
-The stringified value of the Catalyst context object
+=item * The stringified value of the Catalyst context object
 
 =back
 
@@ -836,6 +839,27 @@ This clears the various accessors after saving to the store.
 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
@@ -847,16 +871,16 @@ State plugins must set $c->session ID before C<prepare_action>, and during
 C<prepare_action> L<Catalyst::Plugin::Session> will actually load the data from
 the store.
 
-       sub prepare_action {
-               my $c = shift;
+    sub prepare_action {
+        my $c = shift;
 
-               # don't touch $c->session yet!
+        # don't touch $c->session yet!
 
-               $c->NEXT::prepare_action( @_ );
+        $c->NEXT::prepare_action( @_ );
 
-               $c->session;  # this is OK
-               $c->sessionid; # this is also OK
-       }
+        $c->session;  # this is OK
+        $c->sessionid; # this is also OK
+    }
 
 =head1 CONFIGURATION
 
@@ -974,25 +998,21 @@ plugin should be safe enough.
 
 =head1 AUTHORS
 
-=over 4
-
-=item Andy Grundman
+Andy Grundman
 
-=item Christian Hansen
+Christian Hansen
 
-=item Yuval Kogman, C<nothingmuch@woobling.org> (current maintainer)
+Yuval Kogman, C<nothingmuch@woobling.org> (current maintainer)
 
-=item Sebastian Riedel
-
-=back
+Sebastian Riedel
 
 And countless other contributers from #catalyst. Thanks guys!
 
 =head1 COPYRIGHT & LICENSE
 
-       Copyright (c) 2005 the aforementioned authors. All rights
-       reserved. This program is free software; you can redistribute
-       it and/or modify it under the same terms as Perl itself.
+    Copyright (c) 2005 the aforementioned authors. All rights
+    reserved. This program is free software; you can redistribute
+    it and/or modify it under the same terms as Perl itself.
 
 =cut