Fixed so that session_expires == stored session expires
[catagits/Catalyst-Plugin-Session.git] / t / lib / SessionExpiry / Controller / Root.pm
diff --git a/t/lib/SessionExpiry/Controller/Root.pm b/t/lib/SessionExpiry/Controller/Root.pm
new file mode 100644 (file)
index 0000000..1e4b676
--- /dev/null
@@ -0,0 +1,22 @@
+package SessionExpiry::Controller::Root;
+use strict;
+use warnings;
+
+use base qw/Catalyst::Controller/;
+
+__PACKAGE__->config( namespace => '' );
+
+sub session_data_expires : Global {
+    my ( $self, $c ) = @_;
+    $c->session;
+    if (my $sid = $c->sessionid) {
+        $c->finalize_headers(); # force expiration to be updated
+        $c->res->output($c->get_session_data("expires:$sid"));
+    }
+}
+
+sub session_expires : Global {
+    my ($self, $c) = @_;
+    $c->session;
+    $c->res->output($c->session_expires);
+}