File Coverage

lib/Catalyst/Plugin/Session/State/PSGI.pm
Criterion Covered Total %
statement 12 26 46.1
branch 0 4 0.0
condition 0 2 0.0
subroutine 4 10 40.0
pod 5 6 83.3
total 21 48 43.7


line stmt bran cond sub pod time code
1             package Catalyst::Plugin::Session::State::PSGI;
2             {
3             $Catalyst::Plugin::Session::State::PSGI::VERSION = '0.0.2';
4             }
5             {
6             $Catalyst::Plugin::Session::State::PSGI::DIST = 'Catalyst-Plugin-Session-PSGI';
7             }
8 1     1   49778 use strict;
  1         2  
  1         44  
9 1     1   6 use warnings;
  1         3  
  1         32  
10              
11 1     1   485 use Catalyst::Plugin::Session::PSGI;
  1         2  
  1         32  
12              
13              
14 1     1   6 use base qw/Catalyst::Plugin::Session::State/;
  1         3  
  1         3999  
15              
16              
17              
18              
19              
20              
21             sub prepare_action {
22 0     0 1   my $c = shift;
23             # we don't actually need to do anything here
24 0           $c->maybe::next::method( @_ );
25             }
26              
27             sub get_session_id {
28 0     0 1   my $c = shift;
29 0           my $psgi_env = Catalyst::Plugin::Session::PSGI::_psgi_env($c);
30              
31             return
32 0 0         unless defined $psgi_env;
33              
34 0           my $sid = $psgi_env->{'psgix.session.options'}{id};
35 0 0         return $sid if $sid;
36              
37 0           $c->maybe::next::method( @_ );
38             }
39              
40             sub get_session_expires {
41 0     0 0   my $c = shift;
42 0   0       my $expires = $c->_session_plugin_config->{expires} || 0;
43 0           return time() + $expires;
44             }
45              
46 0     0 1   sub set_session_id { } # unsupported
47              
48 0     0 1   sub set_session_expires { } # unsupported
49              
50 0     0 1   sub delete_session_id { } # unsupported
51              
52             __END__
53              
54             =pod
55              
56             =head1 NAME
57              
58             Catalyst::Plugin::Session::State::PSGI
59              
60             =head1 VERSION
61              
62             version 0.0.2
63              
64             =head1 SYNOPSIS
65              
66             use Catalyst qw/
67             Session
68             Session::State::PSGI
69             Session::Store::PSGI
70             /;
71              
72             =head1 DESCRIPTION
73              
74             An alternative session state plugin that allows session-id retrieval from the
75             PSGI/Plack session information.
76              
77             =head1 EXPERIMENTAL
78              
79             This distribution should be considered B<experimental>. Although functional, it
80             may break in currently undiscovered use cases.
81              
82             =head1 METHODS
83              
84             The plugin provides the following methods:
85              
86             =head2 prepare_action
87              
88             This method may not be required. It's almost a NOOP and may be removed in a
89             future release.
90              
91             =head2 get_session_id
92              
93             This method retrieves the session-id from the PSGI/Plack environment information.
94              
95             =head2
96              
97             This methis returns the time, in epoch seconds, when the session expires.
98              
99             B<NOTE>: This is a small hack that just returns a time far enough into the
100             future for the session not to expire every time you attempt to access it.
101             Actual expiry should be handled by L<Plack::Middleware::Session>.
102              
103             =head2 set_session_id
104              
105             NOOP - unsupported
106              
107             =head2 set_session_expires
108              
109             NOOP - unsupported
110              
111             =head2 delete_session_id
112              
113             NOOP - unsupported
114              
115             =head1 SEE ALSO
116              
117             L<Catalyst::Plugin::Session::PSGI>,
118              
119             1;
120             # ABSTRACT: Session plugin for access to PSGI/Plack session
121             __END__
122             # vim: ts=8 sts=4 et sw=4 sr sta
123              
124             =head1 AUTHOR
125              
126             Chisel <chisel@chizography.net>
127              
128             =head1 COPYRIGHT AND LICENSE
129              
130             This software is copyright (c) 2011 by Chisel Wright.
131              
132             This is free software; you can redistribute it and/or modify it under
133             the same terms as the Perl 5 programming language system itself.
134              
135             =cut