![]() |
![]()
| ![]() |
![]()
NAMEPHP::Session - read / write PHP session files SYNOPSISuse PHP::Session; my $session = PHP::Session->new($id); # session id my $id = $session->id; # get/set session data my $foo = $session->get('foo'); $session->set(bar => $bar); # remove session data $session->unregister('foo'); # remove all session data $session->unset; # check if data is registered $session->is_registered('bar'); # save session data $session->save; # destroy session $session->destroy; # create session file, if not existent $session = PHP::Session->new($new_sid, { create => 1 }); DESCRIPTIONPHP::Session provides a way to read / write PHP4 session files, with which you can make your Perl application session shared with PHP4. If you like Apache::Session interface for session management, there is a glue for Apache::Session of this module, Apache::Session::PHP. OPTIONSConstructor "new" takes some options as hashref.
EXAMPLEuse strict; use PHP::Session; use CGI::Lite; my $session_name = 'PHPSESSID'; # change this if needed print "Content-type: text/plain\n\n"; my $cgi = new CGI::Lite; my $cookies = $cgi->parse_cookies; if ($cookies->{$session_name}) { my $session = PHP::Session->new($cookies->{$session_name}); # now, try to print uid variable from PHP session print "uid:",Dumper($session->get('uid')); } else { print "can't find session cookie $session_name"; } NOTES
TODO
AUTHORTatsuhiko Miyagawa <miyagawa@bulknews.net> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSOApache::Session::PHP, WDDX, Apache::Session, CGI::kSession
|