| 1 | =head1 NAME | ||||||||||||
| 2 | |||||||||||||
| 3 | OpenFrame::WebApp::Segment::Session::CookieLoader - a pipeline segment to load | ||||||||||||
| 4 | sessions from cookies | ||||||||||||
| 5 | |||||||||||||
| 6 | =head1 SYNOPSIS | ||||||||||||
| 7 | |||||||||||||
| 8 | # see OpenFrame::WebApp::Segment::Session::Loader | ||||||||||||
| 9 | |||||||||||||
| 10 | =cut | ||||||||||||
| 11 | |||||||||||||
| 12 | package OpenFrame::WebApp::Segment::Session::CookieLoader; | ||||||||||||
| 13 | |||||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 1 | ▶ | use warnings::register; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | |||||||||||||
| 17 | 1 | ▶ | use OpenFrame::Cookie; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 1 | ▶ | use OpenFrame::Cookies; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | |||||||||||||
| 20 | 1 | our $VERSION = (split(/ /, '$Revision: 1.3 $'))[1]; | |||||||||||
| 21 | |||||||||||||
| 22 | 1 | ▶ | use base qw( OpenFrame::WebApp::Segment::Session::Loader ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 23 | |||||||||||||
| 24 | 1 | our $COOKIE_NAME = 'session'; | |||||||||||
| 25 | |||||||||||||
| 26 | 1 | ▶ | sub create_saver_segment { | ||||||||||
|
Subroutine
create_saver_segment: called CC=1 SCAR=0.2
Pod
documented
| |||||||||||||
| 27 | 1 | my $self = shift; | |||||||||||
| 28 | 1 | my $session = shift; | |||||||||||
| 29 | 1 | $self->create_session_cookie( $session ); | |||||||||||
| 30 | 0 | return $self->SUPER::create_saver_segment( $session ); | |||||||||||
| 31 | } | ||||||||||||
| 32 | |||||||||||||
| 33 | 1 | ▶ | sub find_session_id { | ||||||||||
|
Subroutine
find_session_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 34 | 1 | my $self = shift; | |||||||||||
| 35 | 1 | return $self->look_in_ctin; | |||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | 1 | ▶ | sub look_in_ctin { | ||||||||||
|
Subroutine
look_in_ctin: called CC=3 SCAR=16.5
Pod
undocumented
| |||||||||||||
| 39 | 1 | my $self = shift; | |||||||||||
| 40 | 1 | ▶ | my $ctin = $self->store->get('OpenFrame::Cookies') || return; | ||||||||||
|
Condition50%1/2
$self->store->get('OpenFrame::Cookies') || (return)
MC/DC0%0/1
$self->store->get('OpenFrame::Cookies') || (return)
$self->store->get('OpenFrame::Cookies')
Truth table50%1/2
A
A= $self->store->get('OpenFrame::Cookies')
| |||||||||||||
| 41 | 0 | ▶ | my $cookie = $ctin->get( $COOKIE_NAME ) || return; | ||||||||||
|
Condition0%0/2
$ctin->get($OpenFrame::WebApp::Segment::Session::CookieLoader::COOKIE_NAME) || (return)
MC/DC0%0/1
$ctin->get($OpenFrame::WebApp::Segment::Session::CookieLoader::COOKIE_NAME) || (return)
$ctin->get($OpenFrame::WebApp::Segment::Session::CookieLoader::COOKIE_NAME)
Truth table0%0/2
A
A= $ctin->get($OpenFrame::WebApp::Segment::Session::CookieLoader::COOKIE_NAME)
| |||||||||||||
| 42 | 0 | return $cookie->value(); | |||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | 1 | ▶ | sub create_session_cookie { | ||||||||||
|
Subroutine
create_session_cookie: called CC=1 SCAR=0.5
Pod
undocumented
| |||||||||||||
| 46 | 1 | my $self = shift; | |||||||||||
| 47 | 1 | my $session = shift; | |||||||||||
| 48 | 1 | my $ctin = $self->get_or_create_ctin; | |||||||||||
| 49 | 1 | my $cookie = new OpenFrame::Cookie; | |||||||||||
| 50 | |||||||||||||
| 51 | 1 | $cookie->name( $COOKIE_NAME ); | |||||||||||
| 52 | 0 | $cookie->value( [ $session->id ] ); | |||||||||||
| 53 | |||||||||||||
| 54 | 0 | $ctin->set( $cookie ); | |||||||||||
| 55 | |||||||||||||
| 56 | 0 | return $self; | |||||||||||
| 57 | } | ||||||||||||
| 58 | |||||||||||||
| 59 | 1 | ▶ | sub get_or_create_ctin { | ||||||||||
|
Subroutine
get_or_create_ctin: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||
| 60 | 1 | my $self = shift; | |||||||||||
| 61 | 1 | my $ctin = $self->store->get('OpenFrame::Cookies'); | |||||||||||
| 62 | |||||||||||||
| 63 | 1 | ▶ | unless ($ctin) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 64 | 1 | $ctin = new OpenFrame::Cookies; | |||||||||||
| 65 | 1 | $self->store->set( $ctin ); | |||||||||||
| 66 | } | ||||||||||||
| 67 | |||||||||||||
| 68 | 1 | return $ctin; | |||||||||||
| 69 | } | ||||||||||||
| 70 | |||||||||||||
| 71 | |||||||||||||
| 72 | 1 | 1; | |||||||||||
| 73 | |||||||||||||
| 74 | |||||||||||||
| 75 | __END__ | ||||||||||||