If you are using Apache2, make sure you add this line to your httpd.conf (didn't work for me without it)
LoadModule apreq_module modules/mod_apreq2.so Here is an example to use the CGI::Session with Apache2::Cookie module --------------------------------------------- <% Dumper($cookie_in) %> <% $cookie_in->thaw %> <%init> use Data::Dumper ; use CGI::Session ; my $session = CGI::Session->new() ; my $sessionID = $session->id() ; my $jar = Apache2::Cookie::Jar->new($r) ; my $cookie_in = $jar->cookies('testcookie') ; if (! $cookie_in) { my $out_cookie = Apache2::Cookie->new( $r, -name =>'sessionID', -value => $sessionID) ; $out_cookie->bake($r) ; } </%init> ------------------------------------------------- you probably want the session ID creation on <%once> instead of <%init>. however, this is a simple test that worked for me for Apache2 Cookie module's bake() will put the cookie on outgoing header, ( on the request $r ) and thaw() will give you the value of that cookie from the incoming header. I hope this helps. ------------------------------ Apu Islam ( E Pluribus Unum) ----- Original Message ---- From: Aaron Hawryluk <[EMAIL PROTECTED]> To: mason-users@lists.sourceforge.net Sent: Thursday, November 6, 2008 2:49:35 PM Subject: [Mason] Can't get session working Hi all, I'm new to the list (and Mason - which by the way, is awesome). I have a couple of questions about session and cookie handling. I could seem to find any cookie-cutter recipes out there that worked on my setup (Apache2,mod_perl2,latest Mason) so I thought I'd ask here. I'm just trying to bash this together and haven't dealt with sessions or cookies in Mason before. In my httpd.conf: PerlModule HTML::Mason::ApacheHandler <LocationMatch "/madmin.*\.html$"> PerlSetVar MasonDeclineDirs 0 SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler PerlAddVar MasonAllowGlobals $session %cookies $sid </LocationMatch> in my index.html: <%perl> my $cookie = $r->headers_in->{Cookie} || ''; use CGI::Session; use CGI::Cookie; use Data::Dumper; our %cookies = fetch CGI::Cookie; our $sid = $cookies{'CGISESSID'} || undef; our $session = new CGI::Session('Driver: File', $sid, {Directory=>'/tmp'}); if ( !$cookies{'CGISESSID'} ){ $cookie = new CGI::Cookie(-name => 'CGISESSID', -value =>$session->id(), -path => '/',); $r->headers_out->add('Set-Cookie' => $cookie); } </%perl> <....bunch of html ..> %print "<pre>".Dumper($session)."</pre>\n"; <...more html ...> When I output $session via Dumper I always get $VAR1=undef. Can anyone point me at what I'm doing wrong, or point me at a cookie-cutter recipe that works? --Aaron ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users