line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cookie::Session::Login;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
25336
|
use 5.010000;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
37
|
|
6
|
1
|
|
|
1
|
|
6067
|
use CGI;
|
|
1
|
|
|
|
|
34520
|
|
|
1
|
|
|
|
|
10
|
|
7
|
1
|
|
|
1
|
|
73
|
use vars qw($q);
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
65
|
|
8
|
|
|
|
|
|
|
$q=new CGI;
|
9
|
1
|
|
|
1
|
|
1095
|
use CGI::Cookie;
|
|
1
|
|
|
|
|
2416
|
|
|
1
|
|
|
|
|
694
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
require Exporter;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export
|
16
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead.
|
17
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants.
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# This allows declaration use Cookie::Session::Login ':all';
|
20
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
|
21
|
|
|
|
|
|
|
# will save memory.
|
22
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw(
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
) ] );
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @EXPORT = qw(
|
29
|
|
|
|
|
|
|
new session_start create_cookie cookie_extract http_header_hash redirect_page delete_cookie
|
30
|
|
|
|
|
|
|
);
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $VERSION = '0.01';
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new {
|
35
|
0
|
|
|
0
|
0
|
|
my $class = shift;
|
36
|
0
|
|
|
|
|
|
my $self ={} ;
|
37
|
0
|
|
|
|
|
|
bless ($self,$class);
|
38
|
0
|
|
|
|
|
|
return $self;
|
39
|
|
|
|
|
|
|
}
|
40
|
|
|
|
|
|
|
sub session_start{
|
41
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
42
|
0
|
|
|
|
|
|
(%{$self->{params}}) = @_;
|
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my %hash;
|
44
|
|
|
|
|
|
|
#my $remorteip = $ENV{REMOTE_ADDR};
|
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $cookie_user = new CGI::Cookie(
|
47
|
|
|
|
|
|
|
-name => "$self->{params}{name}",
|
48
|
|
|
|
|
|
|
-value => "$self->{params}{value}",
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
-path => "$self->{params}{path}",
|
51
|
|
|
|
|
|
|
-expires => '+'.$self->{params}{exptime}.'M',
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
);
|
54
|
0
|
|
|
|
|
|
print "Set-Cookie: ",$cookie_user->as_string,"\n";
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
#for(keys %{$self->{params}}) {
|
57
|
|
|
|
|
|
|
# $hash{$_}=$self->{params}{$_};
|
58
|
|
|
|
|
|
|
#}
|
59
|
|
|
|
|
|
|
#cookie_extract( \%hash);
|
60
|
|
|
|
|
|
|
}
|
61
|
|
|
|
|
|
|
sub create_cookie{
|
62
|
0
|
|
|
0
|
1
|
|
my $self = shift;
|
63
|
0
|
|
|
|
|
|
(%{$self->{params}}) = @_;
|
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my %hash;
|
65
|
0
|
|
|
|
|
|
my $cookie_user = new CGI::Cookie(
|
66
|
|
|
|
|
|
|
-name => "$self->{params}{name}",
|
67
|
|
|
|
|
|
|
-value => "$self->{params}{value}",
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
-path => "$self->{params}{path}",
|
70
|
|
|
|
|
|
|
-expires => '+'.$self->{params}{exptime}.'M',
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
);
|
73
|
0
|
|
|
|
|
|
print "Set-Cookie: ",$cookie_user->as_string,"\n";
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
}
|
76
|
|
|
|
|
|
|
sub cookie_extract{
|
77
|
0
|
|
|
0
|
1
|
|
shift;
|
78
|
0
|
|
|
|
|
|
my @array;
|
79
|
|
|
|
|
|
|
my @array1;
|
80
|
|
|
|
|
|
|
#my $ck_name=$ENV{HTTP_COOKIE};
|
81
|
|
|
|
|
|
|
#$ck_name=~/(.*?)\=(.*)/;
|
82
|
|
|
|
|
|
|
#my $cooke_name=$1;
|
83
|
|
|
|
|
|
|
#my $cooke_values=$2;
|
84
|
0
|
|
|
|
|
|
foreach my $name ($q->cookie())
|
85
|
|
|
|
|
|
|
{
|
86
|
0
|
|
|
|
|
|
push(@array,$name);
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
if($_[0] eq "c-name"){
|
90
|
0
|
|
|
|
|
|
return @array;
|
91
|
|
|
|
|
|
|
}
|
92
|
0
|
0
|
|
|
|
|
if($_[0] eq "c-value"){
|
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
foreach my $name ($q->cookie()){
|
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
push(@array1,$q->cookie($name));
|
97
|
|
|
|
|
|
|
}
|
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
return @array1;
|
100
|
|
|
|
|
|
|
}
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
sub http_header_hash{
|
105
|
0
|
|
|
0
|
1
|
|
my %CHash;
|
106
|
0
|
|
|
|
|
|
foreach my $keey(keys %ENV){
|
107
|
0
|
|
|
|
|
|
$CHash{$keey}=$ENV{$keey};
|
108
|
|
|
|
|
|
|
}
|
109
|
0
|
|
|
|
|
|
return %CHash;
|
110
|
|
|
|
|
|
|
}
|
111
|
|
|
|
|
|
|
sub redirect_page{
|
112
|
0
|
|
|
0
|
1
|
|
shift;
|
113
|
0
|
|
|
|
|
|
print $q->redirect("$_[0]");
|
114
|
0
|
|
|
|
|
|
$CGI::HEADERS_ONCE = 1;
|
115
|
|
|
|
|
|
|
}
|
116
|
|
|
|
|
|
|
sub delete_cookie{
|
117
|
0
|
|
|
0
|
1
|
|
shift;
|
118
|
|
|
|
|
|
|
# Delete All Cookie....
|
119
|
0
|
|
|
|
|
|
$CGI::HEADERS_ONCE = 1;
|
120
|
0
|
|
|
|
|
|
foreach my $cooke_name ($q->cookie()){
|
121
|
0
|
|
|
|
|
|
my $cookie_user =
|
122
|
|
|
|
|
|
|
new CGI::Cookie(
|
123
|
|
|
|
|
|
|
-name => "$cooke_name",
|
124
|
|
|
|
|
|
|
-value => "",
|
125
|
|
|
|
|
|
|
-expires => "-1H",
|
126
|
|
|
|
|
|
|
);
|
127
|
0
|
|
|
|
|
|
print "Set-Cookie: ",$cookie_user->as_string,"\n";
|
128
|
|
|
|
|
|
|
}
|
129
|
|
|
|
|
|
|
}
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1;
|
133
|
|
|
|
|
|
|
__END__
|