blib/lib/WebDAO/Sessionco.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 55 CC 2 SCAR 10.3
CC
2
Cov
0%
_init
6.0
get_id
2.0
BEGIN
2.0
CRAP 2.8
1 package WebDAO::Sessionco;
2  
3 =head1 NAME
4  
5 WebDAO::Sessionco - Session with store session id in cookie
6  
7 =head1 DESCRIPTION
8  
9 WebDAO::Sessionco - Session with store session id in cookie
10  
11 =cut
12  
13 our $VERSION = '0.01';
14 use WebDAO;
15 use WebDAO::Session;
16 use MIME::Base64;
17 use Digest::MD5 qw(md5_hex);
18 use base qw( WebDAO::Session );
19 use strict 'vars';
20 use warnings;
21 mk_attr ( Cookie_name=>undef, Db_file=>undef );
22  
23 sub _init {
24  
25 #Parametrs is realm => [string] - for http auth
26 # id =>[string] - name of cookie
27 # db_file => [string] - path and filename
28 #
29 my ( $self, %param ) = @_;
30 $self->SUPER::_init(%param);
31 my $id = $param{id} || "stored";
32 Cookie_name $self (
33 {
34 name => "$id",
35 expires => "+3M",
36 path => "/",
37 value => "0"
38 }
39 );
40 my $cv = $self->Cgi_obj();
41 my $coo = $cv->get_cookie->{ $id };
42 unless ($coo) {
43 $coo = md5_hex(time ^ $$, rand(999)) ;
44 }
45 U_id $self ( $coo );
46 $self->Cookie_name()->{value} = $coo;
47 $self->Cookie_name()->{expires} = time()+ 60*60*24*30*3; # 3 month
48 $cv->set_header('Set-Cookie', $self->Cookie_name());
49 1
50 }
51  
52 sub get_id {
53 my $self = shift;
54 my $coo = U_id $self;
55 return $coo;
56 }
57  
58 1;
59 __DATA__
60  
61 =head1 SEE ALSO
62  
63 http://webdao.sourceforge.net
64  
65 =head1 AUTHOR
66  
67 Zahatski Aliaksandr, E<lt>zag@cpan.orgE<gt>
68  
69 =head1 COPYRIGHT AND LICENSE
70  
71 Copyright 2002-2015 by Zahatski Aliaksandr
72  
73 This library is free software; you can redistribute it and/or modify
74 it under the same terms as Perl itself.
75  
76 =cut
77