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

I'm trying to get CGI::Session to work, but I'm running into some difficulty. I've tried using the sample code that's distributed with the pod, but it's not working either... seems it's just not storing the cookie. Does anyone have any suggestions as to how I could go about troubleshooting this?

#!/usr/bin/perl -w use strict; use CGI; use CGI::Session::DB_File; my ($cgi, $Session, $sid); $cgi = new CGI; $sid = $cgi->cookie("Example2_SID"); $Session = new CGI::Session::DB_File($sid, {FileName=>'sessions.db +', LockDirectory=>'.'}); if ($sid) { $Session->load_param($cgi); } my $cookie = $cgi->cookie(-name=>'Example2_SID', -value=>$Session- +>id, -expires=>"+1d"); print $cgi->header(-cookie=>$cookie), $cgi->start_html("CGI::Session / Example 2"), $cgi->h2("Example 2"); if ($cgi->param('_cmd') eq 'save') { $Session->save_param($cgi); print $cgi->div("Thanks, for your registration. Just hope that + we're not one of those bastards who keep sending you all kinds of sp +am."); } else { $Session->param('name') and print $cgi->div("Wellcome back" . $Session->param('name') +); print $cgi->h2("Please, subscribe to our magazine"); print $cgi->start_form, $cgi->hidden(-name=>'_cmd', -value=>'save'), $cgi->div("Your name:"), $cgi->textfield(-name=>'name', -size=>40), $cgi->div("Your email address:"), $cgi->textfield(-name=>'email', -size=>40),$cgi->br, $cgi->submit(-value=>'Subscribe'), $cgi->end_form; } print $cgi->end_html;

Replies are listed 'Best First'.
Re: CGI::Session problem
by fuzzyping (Chaplain) on Mar 01, 2002 at 21:45 UTC
    I'm sorry everyone, it was PEBCAK. I forgot to edit the db location to a write-permissible directory. My sincerest apologies. Shit.

    -fuzzyping