OpenInteract/Cookies/CGI.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran n/a Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 46 CC 1 SCAR 6.9
CC
1
Cov
0%
parse
2.0
bake
2.0
create_cookie
2.0
CRAP 2.0
1 package OpenInteract::Cookies::CGI;
2  
3 # $Id: CGI.pm,v 1.4 2002/01/02 02:43:53 lachoy Exp $
4  
5 use strict;
6 use CGI::Cookie qw();
7  
8 @OpenInteract::Cookies::CGI::ISA = ();
9 $OpenInteract::Cookies::CGI::VERSION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/);
10  
11  
12 # Parse the cookies using CGI::Cookie
13  
14 sub parse {
15 my ( $class ) = @_;
16 my $R = OpenInteract::Request->instance;
17 my %cookies = CGI::Cookie->fetch;
18 foreach my $name ( keys %cookies ) {
19 my $value = $cookies{ $name }->value;
20 $R->DEBUG && $R->scrib( 2, "Getting cookie $name to $value" );
21 $R->{cookie}{in}{ $name } = $value;
22 }
23 return $R->{cookie}{in};
24 }
25  
26  
27 sub bake {
28 my ( $class ) = @_;
29 my $R = OpenInteract::Request->instance;
30 my $apache = $R->apache;
31 foreach my $name ( keys %{ $R->{cookie}{out} } ) {
32 $R->DEBUG && $R->scrib( 2, "Setting $name to value ", $R->{cookie}{out}{ $name }->value );
33 $apache->header_out( 'Set-Cookie', $R->{cookie}{out}{ $name } )
34 }
35 return 1;
36 }
37  
38  
39 sub create_cookie {
40 my ( $class, $p ) = @_;
41 my $R = OpenInteract::Request->instance;
42 return $R->{cookie}{out}{ $p->{name} } =
43 CGI::Cookie->new( -name => $p->{name},
44 -value => $p->{value},
45 -path => $p->{path},
46 -expires => $p->{expires} );
47 }
48  
49  
50 1;
51  
52 __END__