root/Apache-Session-PHP/trunk/lib/Apache/Session/PHP.pm

Revision 555 (checked in by miyagawa, 19 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 package Apache::Session::PHP;
2
3 use strict;
4 use vars qw($VERSION);
5 $VERSION = 0.01;
6
7 use Apache::Session;
8 use base qw(Apache::Session);
9
10 use Apache::Session::Generate::MD5;
11 use Apache::Session::Serialize::PHP;
12 use Apache::Session::Lock::Null;
13 use Apache::Session::Store::PHP;
14
15 sub populate {
16     my $self = shift;
17
18     $self->{object_store} = Apache::Session::Store::PHP->new($self);
19     $self->{lock_manager} = Apache::Session::Lock::Null->new($self);
20     $self->{generate}     = \&Apache::Session::Generate::MD5::generate;
21     $self->{validate}     = \&Apache::Session::Generate::MD5::validate;
22     $self->{serialize}    = \&Apache::Session::Serialize::PHP::serialize;
23     $self->{unserialize}  = \&Apache::Session::Serialize::PHP::unserialize;
24     return $self;
25 }
26
27 1;
28 __END__
29
30 =head1 NAME
31
32 Apache::Session::PHP - glues Apache::Session with PHP::Session
33
34 =head1 SYNOPSIS
35
36   use Apache::Session::PHP;
37
38   tie %session, 'Apache::Session::PHP', $sid, {
39       SavePath => '/var/sessions',
40   };
41
42 =head1 DESCRIPTION
43
44 Apache::Session::PHP is an adapter of Apache::Session for
45 PHP::Session. It uses following combination of straregies:
46
47 =over 4
48
49 =item Generate: MD5
50
51 PHP4 session also uses 32bit session-id, generated by MD5 of random
52 string. So MD5 (default) generation would fit.
53
54 =item Serialize: PHP
55
56 uses PHP::Session::Serializer::PHP.
57
58 =item Lock: Null
59
60 PHP4 uses exclusive flock for session locking. In Apache::Session, we
61 use Null for locking and Store module executes flock on opening the
62 session file.
63
64 =item Store: PHP
65
66 similarto File store, but file naming scheme is slightly different.
67
68 =back
69
70 =head1 NOTE
71
72 PHP does NOT have distinction between hash and array. Thus
73 PHP::Session restores PHP I<array> as Perl I<hash>.
74
75   Perl  =>  PHP  => Perl
76   array    array    hash
77
78 Thus if you store array in sessions, what'll come back is hash.
79
80 =head1 AUTHOR
81
82 Tatsuhiko Miyagawa E<lt>miyagawa@bulknews.netE<gt>
83
84 This library is free software; you can redistribute it and/or modify
85 it under the same terms as Perl itself.
86
87 =head1 SEE ALSO
88
89 L<Apache::Session>, L<PHP::Session>
90
91 =cut
Note: See TracBrowser for help on using the browser.