| 1 | package MojoX::Session::Transport::Cookie; | ||||||||||
| 2 | |||||||||||
| 3 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 15 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 15 | ▶ | use base 'MojoX::Session::Transport'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 15 | ▶ | use Mojo::Cookie::Request; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 15 | ▶ | use Mojo::Cookie::Response; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 15 | __PACKAGE__->attr(name => 'sid'); | |||||||||
| 12 | 15 | __PACKAGE__->attr(path => '/'); | |||||||||
| 13 | 15 | __PACKAGE__->attr([qw/domain httponly secure/]); | |||||||||
| 14 | |||||||||||
| 15 | 2 | ▶ | sub get { | ||||||||
|
Subroutine
get: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||
| 16 | 2 | my ($self) = @_; | |||||||||
| 17 | |||||||||||
| 18 | 2 | my $cookies = $self->tx->req->cookies; | |||||||||
| 19 | 2 | ▶ | return unless $cookies; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | |||||||||||
| 21 | 2 | my $sid; | |||||||||
| 22 | 2 | foreach my $cookie (@$cookies) { | |||||||||
| 23 | 3 | ▶ | if ($cookie->name eq $self->name) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 2 | return $cookie->value; | |||||||||
| 25 | } | ||||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 0 | return; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 18 | ▶ | sub set { | ||||||||
|
Subroutine
set: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 32 | 18 | my ($self, $sid, $expires) = @_; | |||||||||
| 33 | |||||||||||
| 34 | 18 | my $cookie = Mojo::Cookie::Response->new; | |||||||||
| 35 | |||||||||||
| 36 | 18 | $cookie->name($self->name)->value($sid); | |||||||||
| 37 | 18 | $cookie->path($self->path); | |||||||||
| 38 | 18 | $cookie->domain($self->domain); | |||||||||
| 39 | 18 | $cookie->httponly($self->httponly); | |||||||||
| 40 | 18 | $cookie->secure($self->secure); | |||||||||
| 41 | 18 | $cookie->expires($expires); | |||||||||
| 42 | |||||||||||
| 43 | 18 | ▶ | $cookie->max_age(0) if $expires < time; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | |||||||||||
| 45 | 18 | $self->tx->res->cookies($cookie); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 15 | 1; | |||||||||
| 49 | __END__ | ||||||||||