Revision history for Perl extension Catalyst::Plugin::Session
+ - Fixed bug from last version where session does not persist across a redirect
+
0.34 2012-03-30
- Fixed up t/live_verify_address.t per https://rt.cpan.org/Ticket/Display.html?id=71142
- Merged in dpetrov's 0.32 changes (extend_session_expire)
if ( defined( my $expires = $c->_extended_session_expires ) ) {
return $expires;
} elsif ( defined( $expires = $c->_load_session_expires ) ) {
- return $c->calculate_initial_session_expires;
+ return $c->extend_session_expires( $expires );
} else {
return 0;
}
=item session_expires
-=item session_expires $reset
-
This method returns the time when the current session will expire, or 0 if
there is no current session. If there is a session and it already expired, it
will delete the session and return 0 as well.
-If the C<$reset> parameter is true, and there is a session ID the expiry time
-will be reset to the current time plus the time to live (see
-L</CONFIGURATION>). This is used when creating a new session.
-
=item flash
This is like Ruby on Rails' flash data structure. Think of it as a stash that
--- /dev/null
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More;
+use HTTP::Request::Common;
+
+# setup library path
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+
+use Catalyst::Test 'SessionTestApp';
+my ($res, $c);
+
+($res, $c) = ctx_request(POST 'http://localhost/login', [username => 'bob', password => 's00p3r', remember => 1]);
+is($res->code, 200, 'succeeded');
+my $cookie = $res->header('Set-Cookie');
+ok($cookie, 'Have a cookie');
+
+# this checks that cookie persists across a redirect
+($res, $c) = ctx_request(GET 'http://localhost/logout_persist', Cookie => $cookie);
+is($res->code, 302, '/logout with cookie redirects');
+is($res->header('Location'), 'http://localhost/', 'Redirect to / after logout');
+ok($res->header('Set-Cookie'), 'Cookie is reset by /logout');
+
+done_testing;
$c->delete_session("logout");
}
+sub logout_persist : Global {
+ my ( $self, $c ) = @_;
+ # session is not deleted
+ $c->res->redirect( $c->uri_for('/') );
+}
+
sub set_session_variable : Global {
my ( $self, $c, $var, $val ) = @_;
$c->session->{$var} = $val;