| 1 | package CGI::Builder::Session ; | ||||||||||
| 2 | 3 | $VERSION = 1.26 ; | |||||||||
| 3 | 3 | ▶ | use strict ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | # This file uses the "Perlish" coding style | ||||||||||
| 6 | # please read http://perl.4pro.net/perlish_coding_style.html | ||||||||||
| 7 | |||||||||||
| 8 | ; use CGI::Session | ||||||||||
| 9 | 3 | ▶ | ; $Carp::Internal{+__PACKAGE__}++ | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 3 | ; $Carp::Internal{'CGI::Session'}++ | |||||||||
| 11 | ; use File::Spec | ||||||||||
| 12 | |||||||||||
| 13 | 3 | ▶ | ; use Object::props | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 3 | ▶ | ( { name => 'cs' | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 4 | ▶ | , default => sub{ shift()->cs_new(@_) } | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 16 | } | ||||||||||
| 17 | ) | ||||||||||
| 18 | |||||||||||
| 19 | 3 | ; use Object::groups | |||||||||
| 20 | 3 | ▶ | ( { name => 'cs_new_args' | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | , default | ||||||||||
| 22 | => sub | ||||||||||
| 23 | 4 | ▶ | { return { DSN => undef | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 24 | , SID => $_[0]->cgi | ||||||||||
| 25 | , DSN_param => { Directory => File::Spec->tmpdir } | ||||||||||
| 26 | } | ||||||||||
| 27 | } | ||||||||||
| 28 | } | ||||||||||
| 29 | ) | ||||||||||
| 30 | |||||||||||
| 31 | 3 | ; sub cs_new | |||||||||
| 32 | 4 | ▶ | { my $s = shift | ||||||||
|
Subroutine
cs_new: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||
| 33 | 4 | ; my $args = $s->cs_new_args | |||||||||
| 34 | 4 | ; my $cso = CGI::Session->new( @$args{qw| DSN | |||||||||
| 35 | SID | ||||||||||
| 36 | DSN_param | ||||||||||
| 37 | | | ||||||||||
| 38 | } | ||||||||||
| 39 | ) | ||||||||||
| 40 | 4 | ; $s->cs_init($cso) | |||||||||
| 41 | 4 | ▶ | ; if ($cso->is_new) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 3 | ▶ | { if ( my $new_session_init = $$args{new_session_init} ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 43 | 0 | { $s->$new_session_init($cso) | |||||||||
| 44 | } | ||||||||||
| 45 | } | ||||||||||
| 46 | 4 | ▶ | ; if ( my $session_init = $$args{session_init} ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 0 | { $s->$session_init($cso) | |||||||||
| 48 | } | ||||||||||
| 49 | 4 | ; $cso | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | ; sub cs_init | ||||||||||
| 53 | 4 | ▶ | { my ($s, $cso) = @_ | ||||||||
|
Subroutine
cs_init: called CC=4 SCAR=14.2
Pod
documented
| |||||||||||
| 54 | 4 | ▶ | ; if ( $cso->is_new ) # new session | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | 3 | { my $cs_cookie = $s->cgi->cookie($CGI::Session::NAME => $cso->id) | |||||||||
| 56 | 3 | ; my $cookie_header = $s->header('-cookie') | |||||||||
| 57 | ; $s->header(-cookie => ref $cookie_header eq 'ARRAY' | ||||||||||
| 58 | 0 | ▶ | ? do{ push @$cookie_header, $cs_cookie | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 0 | ▶ | ; $cookie_header | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | } | ||||||||||
| 61 | : $cookie_header | ||||||||||
| 62 | ? [ $cookie_header, $cs_cookie ] | ||||||||||
| 63 | : $cs_cookie | ||||||||||
| 64 | ) | ||||||||||
| 65 | 3 | ; $s->cgi->param($CGI::Session::NAME => $cso->id) | |||||||||
| 66 | } | ||||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 3 | ; 1 | |||||||||
| 70 | |||||||||||
| 71 | __END__ | ||||||||||