blib/lib/CGI/Application/Plugin/Session.pm

filter: Statementstmt 83.3% 115 / 138 Branchbran 84.1% 69 / 82 Conditioncond 61.2% 30 / 49 MC/DCmcdc 44.8% 13 / 29 Subroutinesub 81.2% 13 / 16 Podpod 100% 6 / 6 totaltotal 76.8% 246 / 320 CC 60 SCAR 26.1
CC
60
Cov
80%
__locate_session_name
30.0
session_recreate
20.0
session
17.1
CRAP 13.5
↑ Summary
1 package CGI::Application::Plugin::Session;
2 13 $CGI::Application::Plugin::Session::VERSION = '1.06';
3 13 ▶use CGI::Session ();
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use CGI::Application 3.21;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # ABSTRACT: Plugin that adds session support to CGI::Application
10  
11 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 13 ▶use vars qw($VERSION @EXPORT);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 13 require Exporter;
15  
16 13 @EXPORT = qw(
17 session
18 session_config
19 session_cookie
20 session_delete
21 session_loaded
22 session_recreate
23 );
24 24 ▶sub import { goto &Exporter::import }
Subroutine import: called CC=1 SCAR=0.0
25  
26 104 ▶sub session {
Subroutine session: called CC=16 SCAR=28.4
Pod documented
27 104 my $self = shift;
28  
29 104 ▶ if (!$self->{__CAP__SESSION_OBJ}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"__CAP__SESSION_OBJ"}) 29 75 104
30 # define the config hash if it doesn't exist to save some checks later
31 29 ▶ $self->{__CAP__SESSION_CONFIG} = {} unless $self->{__CAP__SESSION_CONFIG};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"__CAP__SESSION_CONFIG"} 1 28 29
32  
33 # gather parameters for the CGI::Session module from the user,
34 # or use some sane defaults
35 my @params = ($self->{__CAP__SESSION_CONFIG}->{CGI_SESSION_OPTIONS}) ?
36 29 ▶ @{ $self->{__CAP__SESSION_CONFIG}->{CGI_SESSION_OPTIONS} } :
Branch: 1 branch
BranchTrueFalseTotal
$self->{'__CAP__SESSION_CONFIG'}{'CGI_SESSION_OPTIONS'} ? : 28 1 29
37 ('driver:File', $self->query, {Directory=>File::Spec->tmpdir});
38  
39  
40 # CGI::Session only works properly with CGI.pm so extract the sid manually if
41 # another module is being used
42 29 ▶ if (Scalar::Util::blessed($params[1]) && ! $params[1]->isa('CGI')) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($params[1]) and not $params[1]->isa("CGI")) 0 29 29
Condition66%2/3
builtin::blessed($params[1]) and not $params[1]->isa("CGI")
!ll&&!rl&&r
7220
MC/DC0%0/2
builtin::blessed($params[1]) and not $params[1]->isa("CGI")
builtin::blessed($params[1]) not $params[1]->isa("CGI")
Truth table66%2/3
A and not(B)
A= builtin::blessed($params[1])B= not $params[1]->isa("CGI")
ABresult
0X0
100
111
43 0 my $name = __locate_session_name( $self ); ## plugin method call
44 0 ▶+ my $sid = $params[1]->cookie($name) || $params[1]->param($name);
Condition0%0/3
$params[1]->cookie($name) || $params[1]->param($name)
l!l&&r!l&&!r
000
MC/DC0%0/2
$params[1]->cookie($name) || $params[1]->param($name)
$params[1]->cookie($name) $params[1]->param($name)
Truth table0%0/3
A || B
A= $params[1]->cookie($name)B= $params[1]->param($name)
ABresult
1X1
011
000
45 0 $params[1] = $sid;
46 }
47  
48 # create CGI::Session object or die with an error
49 29 $self->{__CAP__SESSION_OBJ} = CGI::Session->new(@params);
50 29 ▶ if (! $self->{__CAP__SESSION_OBJ} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"__CAP__SESSION_OBJ"}) 1 28 29
51 1 ▶ my $errstr = CGI::Session->errstr || 'Unknown';
Condition50%1/2
'CGI::Session'->errstr || 'Unknown'
l!l
10
MC/DC0%0/1
'CGI::Session'->errstr || 'Unknown'
'CGI::Session'->errstr
Truth table50%1/2
A
A= 'CGI::Session'->errstr
Aresult
11
00
52 1 croak "Failed to Create CGI::Session object :: Reason: $errstr";
53 }
54  
55 # Set the default expiry if requested and if this is a new session
56 28 ▶ if ($self->{__CAP__SESSION_CONFIG}->{DEFAULT_EXPIRY} && $self->{__CAP__SESSION_OBJ}->is_new) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"__CAP__SESSION_CONFIG"}{"DEFAULT_EXPIRY"} and $self->{"__CAP__SESSION_OBJ"}->is_new) 11 17 28
Condition100%3/3
$self->{"__CAP__SESSION_CONFIG"}{"DEFAULT_EXPIRY"} and $self->{"__CAP__SESSION_OBJ"}->is_new
!ll&&!rl&&r
15211
MC/DC100%2/2
$self->{"__CAP__SESSION_CONFIG"}{"DEFAULT_EXPIRY"} and $self->{"__CAP__SESSION_OBJ"}->is_new
$self->{"__CAP__SESSION_CONFIG"}{"DEFAULT_EXPIRY"} $self->{"__CAP__SESSION_OBJ"}->is_new
Truth table100%3/3
A and B
A= $self->{"__CAP__SESSION_CONFIG"}{"DEFAULT_EXPIRY"}B= $self->{"__CAP__SESSION_OBJ"}->is_new
ABresult
0X0
100
111
57 11 $self->{__CAP__SESSION_OBJ}->expire($self->{__CAP__SESSION_CONFIG}->{DEFAULT_EXPIRY});
58 }
59  
60 # add the cookie to the outgoing headers under the following conditions
61 # if the cookie doesn't exist,
62 # or if the session ID doesn't match what is in the current cookie,
63 # or if the session has an expiry set on it
64 # but don't send it if SEND_COOKIE is set to 0
65 28 ▶ if (!defined $self->{__CAP__SESSION_CONFIG}->{SEND_COOKIE} || $self->{__CAP__SESSION_CONFIG}->{SEND_COOKIE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"} or $self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"}) 26 2 28
Condition100%3/3
not defined $self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"} or $self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"}
l!l&&r!l&&!r
16102
MC/DC100%2/2
not defined $self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"} or $self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"}
not defined $self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"} $self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"}
Truth table100%3/3
not(A) or B
A= not defined $self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"}B= $self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"}
ABresult
1X1
011
000
66 my $cid = $self->query->cookie(
67 $self->{__CAP__SESSION_OBJ}->name
68 26 );
69 26 ▶ if (!$cid || $cid ne $self->{__CAP__SESSION_OBJ}->id || $self->{__CAP__SESSION_OBJ}->expire()) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $cid or $cid ne $self->{"__CAP__SESSION_OBJ"}->id or $self->{"__CAP__SESSION_OBJ"}->expire) 23 3 26
Condition100%6/6
not $cid or $cid ne $self->{"__CAP__SESSION_OBJ"}->id or $self->{"__CAP__SESSION_OBJ"}->expire
l!l&&r!l&&!r
2123
not $cid or $cid ne $self->{"__CAP__SESSION_OBJ"}->id
l!l&&r!l&&!r
1655
MC/DC100%3/3
not $cid or $cid ne $self->{"__CAP__SESSION_OBJ"}->id or $self->{"__CAP__SESSION_OBJ"}->expire
not $cid $cid ne $self->{"__CAP__SESSION_OBJ"}->id $self->{"__CAP__SESSION_OBJ"}->expire
Truth table100%4/4
not(A) or B or C
A= not $cidB= $cid ne $self->{"__CAP__SESSION_OBJ"}->idC= $self->{"__CAP__SESSION_OBJ"}->expire
ABCresult
1XX1
01X1
0011
0000
70 23 session_cookie($self);
71 }
72 }
73 }
74  
75 103 return $self->{__CAP__SESSION_OBJ};
76 }
77  
78 34 ▶sub session_config {
Subroutine session_config: called CC=12 SCAR=24.8
Pod documented
79 34 my $self = shift;
80  
81 34 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 33 1 34
82 33 ▶ die "Calling session_config after the session has already been created" if (defined $self->{__CAP__SESSION_OBJ});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"__CAP__SESSION_OBJ"} 2 31 33
83 31 my $props;
84 31 ▶ if (ref($_[0]) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 10 21 31
85 10 $props = $self->_cap_hash($_[0]);
86 } else {
87 21 $props = $self->_cap_hash({ @_ });
88 }
89  
90 # Check for CGI_SESSION_OPTIONS
91 31 ▶ if ($props->{CGI_SESSION_OPTIONS}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($props->{"CGI_SESSION_OPTIONS"}) 29 2 31
92 29 ▶ die "session_config error: parameter CGI_SESSION_OPTIONS is not an array reference" if ref $props->{CGI_SESSION_OPTIONS} ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $props->{"CGI_SESSION_OPTIONS"} ne "ARRAY" 1 28 29
93 28 $self->{__CAP__SESSION_CONFIG}->{CGI_SESSION_OPTIONS} = delete $props->{CGI_SESSION_OPTIONS};
94 }
95  
96 # Check for COOKIE_PARAMS
97 30 ▶ if ($props->{COOKIE_PARAMS}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($props->{"COOKIE_PARAMS"}) 12 18 30
98 12 ▶ die "session_config error: parameter COOKIE_PARAMS is not a hash reference" if ref $props->{COOKIE_PARAMS} ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $props->{"COOKIE_PARAMS"} ne "HASH" 1 11 12
99 11 $self->{__CAP__SESSION_CONFIG}->{COOKIE_PARAMS} = delete $props->{COOKIE_PARAMS};
100 }
101  
102 # Check for SEND_COOKIE
103 29 ▶ if (defined $props->{SEND_COOKIE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $props->{"SEND_COOKIE"}) 12 17 29
104 12 ▶ $self->{__CAP__SESSION_CONFIG}->{SEND_COOKIE} = (delete $props->{SEND_COOKIE}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
delete $props->{'SEND_COOKIE'} ? : 10 2 12
105 }
106  
107 # Check for DEFAULT_EXPIRY
108 29 ▶ if (defined $props->{DEFAULT_EXPIRY}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $props->{"DEFAULT_EXPIRY"}) 13 16 29
109 13 $self->{__CAP__SESSION_CONFIG}->{DEFAULT_EXPIRY} = delete $props->{DEFAULT_EXPIRY};
110 }
111  
112 # If there are still entries left in $props then they are invalid
113 29 ▶ die "Invalid option(s) (".join(', ', keys %$props).") passed to session_config" if %$props;
Branch: 1 branch
BranchTrueFalseTotal
if %$props 1 28 29
114 }
115  
116 29 $self->{__CAP__SESSION_CONFIG};
117 }
118  
119 24 ▶sub session_cookie {
Subroutine session_cookie: called CC=15 SCAR=27.1
Pod documented
120 24 my $self = shift;
121 24 my %options = @_;
122  
123 # merge in any parameters set by config_session
124 24 ▶ if ($self->{__CAP__SESSION_CONFIG}->{COOKIE_PARAMS}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"__CAP__SESSION_CONFIG"}{"COOKIE_PARAMS"}) 11 13 24
125 11 %options = (%{ $self->{__CAP__SESSION_CONFIG}->{COOKIE_PARAMS} }, %options);
126 }
127  
128 24 ▶ if (!$self->{__CAP__SESSION_OBJ}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"__CAP__SESSION_OBJ"}) 1 23 24
129 # The session object has not been created yet, so make sure we at least call it once
130 1 my $tmp = $self->session;
131 }
132  
133 ## check cookie option -name with session name
134 ## if different these may cause problems/confusion
135 24 ▶ if ( exists $options{'-name'} and
Branch: 1 branch
BranchTrueFalseTotal
if (exists $options{"-name"} and $options{"-name"} ne $self->session->name) 1 23 24
Condition100%3/3
exists $options{"-name"} and $options{"-name"} ne $self->session->name
!ll&&!rl&&r
1851
MC/DC100%2/2
exists $options{"-name"} and $options{"-name"} ne $self->session->name
exists $options{"-name"} $options{"-name"} ne $self->session->name
Truth table100%3/3
A and B
A= exists $options{"-name"}B= $options{"-name"} ne $self->session->name
ABresult
0X0
100
111
136 $options{'-name'} ne $self->session->name ) {
137 warn sprintf( "Cookie '%s' and Session '%s' name don't match.\n",
138 1 $options{'-name'}, $self->session->name )
139 }
140  
141 ## setup the values for cookie
142 24 ▶ $options{'-name'} ||= $self->session->name;
Condition66%2/3
$options{"-name"} ||= $self->session->name
l!l&&r!l&&!r
6180
MC/DC0%0/2
$options{"-name"} ||= $self->session->name
$options{"-name"} $self->session->name
Truth table66%2/3
A ||= B
A= $options{"-name"}B= $self->session->name
ABresult
1X1
011
000
143 24 ▶ $options{'-value'} ||= $self->session->id;
Condition66%2/3
$options{"-value"} ||= $self->session->id
l!l&&r!l&&!r
5190
MC/DC0%0/2
$options{"-value"} ||= $self->session->id
$options{"-value"} $self->session->id
Truth table66%2/3
A ||= B
A= $options{"-value"}B= $self->session->id
ABresult
1X1
011
000
144 24 ▶ if(defined($self->session->expires()) && !defined($options{'-expires'})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->session->expires and not defined $options{"-expires"}) 5 19 24
Condition100%3/3
defined $self->session->expires and not defined $options{"-expires"}
!ll&&!rl&&r
1185
MC/DC100%2/2
defined $self->session->expires and not defined $options{"-expires"}
defined $self->session->expires not defined $options{"-expires"}
Truth table100%3/3
A and not(B)
A= defined $self->session->expiresB= not defined $options{"-expires"}
ABresult
0X0
100
111
145 5 $options{'-expires'} = _build_exp_time( $self->session->expires() );
146 }
147 24 my $cookie = $self->query->cookie(%options);
148  
149 # Look for a cookie header in the existing headers
150 24 my %headers = $self->header_props;
151 24 my $cookie_set = 0;
152 24 ▶ if (my $cookies = $headers{'-cookie'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cookies = $headers{"-cookie"}) 4 20 24
153 4 ▶ if (ref($cookies) eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $cookies eq 'ARRAY') { } 2 2 4
elsif (substr($cookies, 0, length $options{'-name'}) eq $options{'-name'}) { } 1 1 2
154 # multiple cookie headers so check them all
155 2 ▶ for (my $i=0; $i < @$cookies; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$cookies) 4 2 6
156 # replace the cookie inline if we find a match
157 4 ▶ if (substr($cookies->[$i], 0, length($options{'-name'})) eq $options{'-name'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($cookies->[$i], 0, length $options{"-name"}) eq $options{"-name"}) 1 3 4
158 1 $cookies->[$i] = $cookie;
159 1 $cookie_set++;
160 }
161 }
162 } elsif (substr($cookies, 0, length($options{'-name'})) eq $options{'-name'}) {
163 # only one cookie and it is ours, so overwrite it
164 1 $self->header_add(-cookie => $cookie);
165 1 $cookie_set++;
166 }
167 }
168  
169 24 ▶ $self->header_add(-cookie => [$cookie]) unless $cookie_set;
Branch: 1 branch
BranchTrueFalseTotal
unless $cookie_set 22 2 24
170  
171 24 return 1;
172 }
173  
174 5 ▶sub _build_exp_time {
Subroutine _build_exp_time: called CC=3 SCAR=11.0
175 5 my $secs_until_expiry = shift;
176 5 ▶ return unless defined $secs_until_expiry;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $secs_until_expiry 0 5 5
177  
178 # Add a plus sign unless the number is negative
179 5 ▶ my $prefix = ($secs_until_expiry >= 0) ? '+' : '';
Branch: 1 branch
BranchTrueFalseTotal
$secs_until_expiry >= 0 ? : 4 1 5
180  
181 # Add an 's' for "seconds".
182 5 return $prefix.$secs_until_expiry.'s';
183 }
184  
185 3 ▶sub session_delete {
Subroutine session_delete: called CC=11 SCAR=24.3
Pod documented
186 3 my $self = shift;
187  
188 3 ▶ if ( my $session = $self->session ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $session = $self->session) 3 0 3
189 3 $session->delete;
190 3 $session->flush;
191 3 ▶ if ( $self->{'__CAP__SESSION_CONFIG'}->{'SEND_COOKIE'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"__CAP__SESSION_CONFIG"}{"SEND_COOKIE"}) 3 0 3
192 3 my %options;
193 3 ▶ if ( $self->{'__CAP__SESSION_CONFIG'}->{'COOKIE_PARAMS'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"__CAP__SESSION_CONFIG"}{"COOKIE_PARAMS"}) 3 0 3
194 3 %options = ( %{ $self->{'__CAP__SESSION_CONFIG'}->{'COOKIE_PARAMS'} }, %options );
195 }
196 3 ▶ $options{'name'} ||= $session->name;
Condition33%1/3
$options{"name"} ||= $session->name
l!l&&r!l&&!r
030
MC/DC0%0/2
$options{"name"} ||= $session->name
$options{"name"} $session->name
Truth table33%1/3
A ||= B
A= $options{"name"}B= $session->name
ABresult
1X1
011
000
197 3 $options{'value'} = '';
198 3 $options{'-expires'} = '-1d';
199 3 my $newcookie = $self->query->cookie(\%options);
200  
201 # See if a session cookie has already been set (this will happen if
202 # this is a new session). We keep all existing cookies except the
203 # session cookie, which we replace with the timed out session
204 # cookie
205 3 my @keep;
206 3 my %headers = $self->header_props;
207 3 ▶ my $cookies = $headers{'-cookie'} || [];
Condition50%1/2
$headers{'-cookie'} || []
l!l
30
MC/DC0%0/1
$headers{'-cookie'} || []
$headers{'-cookie'}
Truth table50%1/2
A
A= $headers{'-cookie'}
Aresult
11
00
208 3 ▶ $cookies = [$cookies] unless ref $cookies eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cookies eq "ARRAY" 1 2 3
209 3 foreach my $cookie (@$cookies) {
210 5 ▶ if ( ref($cookie) ne 'CGI::Cookie' || $cookie->name ne $session->name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $cookie ne "CGI::Cookie" or $cookie->name ne $session->name) 3 2 5
Condition100%3/3
ref $cookie ne "CGI::Cookie" or $cookie->name ne $session->name
l!l&&r!l&&!r
212
MC/DC100%2/2
ref $cookie ne "CGI::Cookie" or $cookie->name ne $session->name
ref $cookie ne "CGI::Cookie" $cookie->name ne $session->name
Truth table100%3/3
A or B
A= ref $cookie ne "CGI::Cookie"B= $cookie->name ne $session->name
ABresult
1X1
011
000
211 # keep this cookie
212 3 push @keep, $cookie;
213 }
214 }
215 3 push @keep, $newcookie;
216  
217 # We have to set the cookies this way, because CGI::Application has
218 # an annoying interface to the headers (why can't we have
219 # 'header_set as well as header_add?). The first call replaces all
220 # cookie headers with the one new cookie header, and the next call
221 # adds in the rest of the cookies if there are any.
222 3 $self->header_add( -cookie => shift @keep );
223 3 ▶ $self->header_add( -cookie => \@keep ) if @keep;
Branch: 1 branch
BranchTrueFalseTotal
if @keep 2 1 3
224 }
225 }
226 }
227  
228 0 ▶sub session_loaded {
Subroutine session_loaded: not called CC=1 SCAR=6.9
Pod documented
229 0 my $self = shift;
230 0 return defined $self->{__CAP__SESSION_OBJ};
231 }
232  
233 0 ▶sub session_recreate {
Subroutine session_recreate: not called CC=4 SCAR=30.0
Pod documented
234 0 my $self = shift;
235 0 my $data = {};
236  
237 # Copy all values from existing session and delete it
238 0 ▶ if (session_loaded($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (session_loaded($self)) 0 0 0
239 0 $data = $self->session->param_hashref;
240 0 $self->session->delete;
241 0 $self->session->flush;
242 0 $self->{__CAP__SESSION_OBJ} = undef;
243  
244 }
245  
246 # create a new session and populate it
247 # (This should also send out a new cookie if so configured)
248 0 my $session = $self->session;
249 0 ▶ while(my($k,$v) = each %$data) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$data) 0 0 0
250 0 ▶ next if index($k, '_SESSION_') == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($k, "_SESSION_") == 0 0 0 0
251 0 $session->param($k => $v);
252 }
253 0 $session->flush;
254  
255 0 return 1;
256 }
257  
258 ## all a hack to adjust for problems with cgi::session and
259 ## it not playing with non-CGI.pm objects
260 0 ▶sub __locate_session_name {
Subroutine __locate_session_name: not called CC=5 SCAR=34.0
261 0 my $self = shift;
262 0 my $sess_opts = $self->{__CAP__SESSION_CONFIG}->{CGI_SESSION_OPTIONS};
263  
264 ## search for 'name' cgi session option
265 0 ▶ if ( $sess_opts and $sess_opts->[4]
Branch: 1 branch
BranchTrueFalseTotal
if ($sess_opts and $sess_opts->[4] and ref $sess_opts->[4] eq "HASH" and exists $sess_opts->[4]{"name"}) 0 0 0
Condition0%0/9
$sess_opts and $sess_opts->[4] and ref $sess_opts->[4] eq "HASH" and exists $sess_opts->[4]{"name"}
!ll&&!rl&&r
000
$sess_opts and $sess_opts->[4] and ref $sess_opts->[4] eq "HASH"
!ll&&!rl&&r
000
$sess_opts and $sess_opts->[4]
!ll&&!rl&&r
000
MC/DC0%0/4
$sess_opts and $sess_opts->[4] and ref $sess_opts->[4] eq "HASH" and exists $sess_opts->[4]{"name"}
$sess_opts $sess_opts->[4] ref $sess_opts->[4] eq "HASH" exists $sess_opts->[4]{"name"}
Truth table0%0/5
A and B and C and D
A= $sess_optsB= $sess_opts->[4]C= ref $sess_opts->[4] eq "HASH"D= exists $sess_opts->[4]{"name"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
266 and ref $sess_opts->[4] eq 'HASH'
267 and exists $sess_opts->[4]->{name} ) {
268 0 return $sess_opts->[4]->{name};
269 }
270  
271 0 return CGI::Session->name;
272 }
273  
274 13 1;
275  
276 __END__
↑ Summary