http://www.perlmonks.org?node_id=1061159

httpd has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am new to mod_perl, and I want to manage sessions on my site, however I cannot create it, please help.

I am trying to use Apache::Session::File module, and my code looks like the following:

use Apache2::Request; use Apache::Session::File; use warnings; #read cookie if this is an running session my $r = Apache2::RequestUtil->request; my $cookie = $r->headers_in('Cookie'); #Create a session object based on the cookie my %session; tie %session, 'Apache::Session::File', $cookie, { Directory => '/tmp/plsessions', LockDirectory => '/tmp/plsessionlock', }; # if a new session, give it cookie back my $session_cookie = "SESSION_ID=$session{_session_id};"; $r->headers_out("Set-Cookie" => $session_cookie);

when trying to run that script from browser I get following in error_log:

[Tue Nov 05 00:01:34 2013] [error] argument is not a blessed reference + (expecting an APR::Table derived object) at scripts/login.pl line 8. +\n

If anybody has a sample example on howto use sessions with mod_perl2, i would appreciate if you share. PS. I was trying to install perl-Apache-SessionManager, however it fails:

~# rpm -Uvh perl-Apache-SessionManager-1.03-1.2.el6.rf.noarch.rpm error: Failed dependencies: perl(mod_perl) is needed by perl-Apache-SessionManager-1.03-1. +2.el6.rf.noarch # rpm -q mod_perl mod_perl-2.0.4-10.el6.x86_64

That's strange because in description perl-Apache-SessionManager supports mod_perl2

Any help kindly appreciated

Replies are listed 'Best First'.
Re: mod_perl2 sessions?
by Anonymous Monk on Nov 05, 2013 at 01:29 UTC
    Well, I doubt $cookie is a sessionid, the kind you're expecting
      do you have any example of creating session with mod_perl2? I cannot find it :(