aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/TestMech.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/TestMech.pm')
-rw-r--r--perllib/FixMyStreet/TestMech.pm24
1 files changed, 24 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/TestMech.pm b/perllib/FixMyStreet/TestMech.pm
index 3d011d708..c16f288c8 100644
--- a/perllib/FixMyStreet/TestMech.pm
+++ b/perllib/FixMyStreet/TestMech.pm
@@ -280,4 +280,28 @@ sub visible_form_values {
return \%params;
}
+=head2 session_cookie_expiry
+
+ $expiry = $mech->session_cookie_expiry( );
+
+Returns the current expiry time for the session cookie. Might be '0' which
+indicates it expires at end of browser session.
+
+=cut
+
+sub session_cookie_expiry {
+ my $mech = shift;
+
+ my $cookie_name = 'fixmystreet_app_session';
+ my $expires = 'not found';
+
+ $mech #
+ ->cookie_jar #
+ ->scan( sub { $expires = $_[8] if $_[1] eq $cookie_name } );
+
+ croak "Could not find cookie '$cookie_name'" if $expires eq 'not found';
+
+ return $expires || 0;
+}
+
1;