File Coverage

blib/lib/Apache/Session/Generate/ModUniqueId.pm
Criterion Covered Total %
statement 9 13 69.2
branch 1 4 25.0
condition n/a
subroutine 3 4 75.0
pod 0 2 0.0
total 13 23 56.5


line stmt bran cond sub pod time code
1             package Apache::Session::Generate::ModUniqueId;
2              
3 1     1   2377 use strict;
  1         3  
  1         37  
4 1     1   5 use vars qw($VERSION);
  1         2  
  1         216  
5             $VERSION = '0.02';
6              
7             sub generate {
8 1     1 0 610 my $session = shift;
9 1 50       5 unless (exists $ENV{UNIQUE_ID}) {
10 0         0 require Carp;
11 0         0 Carp::croak('Can\'t get UNIQUE_ID env variable. Make sure mod_unique_id is enabled.');
12             }
13 1         5 $session->{data}->{_session_id} = $ENV{UNIQUE_ID};
14             }
15              
16             sub validate {
17 0     0 0   my $session = shift;
18 0 0         $session->{data}->{_session_id} =~ /^[A-Za-z0-9@\-]+$/
19             or die "invalid session id: $session->{data}->{_session_id}.";
20             }
21              
22             1;
23             __END__
24              
25             =head1 NAME
26              
27             Apache::Session::Generate::ModUniqueId - mod_unique_id for session ID generation
28              
29             =head1 SYNOPSIS
30              
31             use Apache::Session::Flex;
32              
33             tie %session, 'Apache::Session::Flex', $id, {
34             Store => 'MySQL',
35             Lock => 'Null',
36             Generate => 'ModUniqueId',
37             Serialize => 'Storable',
38             };
39              
40             =head1 DESCRIPTION
41              
42             Apache::Session::Generate::ModUniqueId enables you to use unique id
43             generated by mod_unique_id as session id for Apache::Session
44             framework. Using mod_unique_id would ensure higher level uniquess of
45             id.
46              
47             =head1 AUTHOR
48              
49             Tatsuhiko Miyagawa <miyagawa@bulknews.net>
50              
51             This library is free software; you can redistribute it and/or modify
52             it under the same terms as Perl itself.
53              
54             =head1 SEE ALSO
55              
56             L<Apache::Session>, L<Apache::Session::Flex>, mod_unique_id
57              
58             =cut