| 1 | package Mojolicious::Sessions::ThreeS::State::Cookie; | ||||||||||||
| 2 | 3 | $Mojolicious::Sessions::ThreeS::State::Cookie::VERSION = '0.004'; | |||||||||||
| 3 | 3 | ▶ | use Mojo::Base qw/Mojolicious::Sessions::ThreeS::State/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | =head1 NAME | ||||||||||||
| 6 | |||||||||||||
| 7 | Mojolicious::Sessions::ThreeS::State::Cookie - A cookie based session ID manager | ||||||||||||
| 8 | |||||||||||||
| 9 | =cut | ||||||||||||
| 10 | |||||||||||||
| 11 | 3 | has 'cookie_domain'; | |||||||||||
| 12 | 3 | has 'cookie_name' => 'sessions3sid'; | |||||||||||
| 13 | 3 | has 'cookie_path' => '/'; | |||||||||||
| 14 | |||||||||||||
| 15 | 3 | has 'http_only' => 1; | |||||||||||
| 16 | 3 | has 'secure'; | |||||||||||
| 17 | |||||||||||||
| 18 | =head2 cookie_domain | ||||||||||||
| 19 | |||||||||||||
| 20 | =head2 cookie_name | ||||||||||||
| 21 | |||||||||||||
| 22 | Defaults to C<sessions3sid> | ||||||||||||
| 23 | |||||||||||||
| 24 | =head2 cookie_path | ||||||||||||
| 25 | |||||||||||||
| 26 | Defaults to C<cookie_path> | ||||||||||||
| 27 | |||||||||||||
| 28 | =head2 http_only | ||||||||||||
| 29 | |||||||||||||
| 30 | Defautls to C<1> | ||||||||||||
| 31 | |||||||||||||
| 32 | =head2 secure | ||||||||||||
| 33 | |||||||||||||
| 34 | Defaults to C<undef> | ||||||||||||
| 35 | |||||||||||||
| 36 | =head2 get_session_id | ||||||||||||
| 37 | |||||||||||||
| 38 | See L<Mojolicious::Sessions::ThreeS::State> | ||||||||||||
| 39 | |||||||||||||
| 40 | =cut | ||||||||||||
| 41 | |||||||||||||
| 42 | 36 | ▶ | sub get_session_id{ | ||||||||||
|
Subroutine
get_session_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 43 | 36 | my ($self, $controller) = @_; | |||||||||||
| 44 | 36 | return $controller->signed_cookie( $self->cookie_name() ); | |||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | =head2 set_session_id | ||||||||||||
| 48 | |||||||||||||
| 49 | See L<Mojolicious::Sessions::ThreeS::State> | ||||||||||||
| 50 | |||||||||||||
| 51 | =cut | ||||||||||||
| 52 | |||||||||||||
| 53 | 14 | ▶ | sub set_session_id{ | ||||||||||
|
Subroutine
set_session_id: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||
| 54 | 14 | my ( $self, $controller, $session_id , $opts ) = @_; | |||||||||||
| 55 | 14 | ▶ | $opts //= {}; | ||||||||||
|
Condition50%1/2
$opts //= {}
MC/DC0%0/1
$opts //= {}
$opts
Truth table50%1/2
A
A= $opts
| |||||||||||||
| 56 | $controller->signed_cookie( | ||||||||||||
| 57 | $self->cookie_name, | ||||||||||||
| 58 | $session_id, | ||||||||||||
| 59 | { | ||||||||||||
| 60 | domain => scalar( $self->cookie_domain ), | ||||||||||||
| 61 | 14 | ▶ | ( $opts->{expires} ? ( expires => $opts->{expires} ) : () ), | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 62 | httponly => $self->http_only, | ||||||||||||
| 63 | path => $self->cookie_path(), | ||||||||||||
| 64 | secure => $self->secure() | ||||||||||||
| 65 | } | ||||||||||||
| 66 | ); | ||||||||||||
| 67 | } | ||||||||||||
| 68 | |||||||||||||
| 69 | |||||||||||||
| 70 | 3 | 1; | |||||||||||