Hi,

I'm trying to use Apache::Session::DBI. I got the hang of it and 
started using it but I get the following error:

[Thu Mar 30 04:41:41 2000] [error] Can't call method "store" on 
unblessed reference at lib/web/webmaster.p
l line 54.

Now, lines 49-54 on lib/web/webmaster.pl look like this (I added line 
numbers):

49 sub carry_on {
50 my $htdocs_dir = $SETUP::htdocs_dir;
51 my $p = $$query->param('p'); #which page user selected
52 my $do = $$query->param('do'); #which page user selected
53 $session->{'already_reged'} = 1; #so user can't submit this form 
ever again!
54 $session->store();
...
}

Alot of other stuff come after this but it doesn't really matter :)

Anyway, there's another routine, called main, that creates a session 
and then calls carry_on. Here's the routine with the two lines that 
come before it:

package WEBMASTER;
use strict;
sub main {
use vars qw($query $sid $session %session); #making these variables 
global
local $query = \$MAIN::query;

local ($sid,$session,%session); #session stuff
my ($rc,$adv); #recommender, advertiser

if (!$$query->param('sid'))
        {
        #make a fresh session for a first-time visitor
        my $opts = {    'subclass-specific' => 'option overrides',      'autocommit' 
=> '0', 'lifetime' => $SETUP::default_session_timeout};
        $session = Apache::Session::DBI->new($opts);
        tie %session, 'Apache::Session::DBI', undef;

        #define variables
        $sid = $session->{'_ID'};
        $rc = $$query->param('rc'); #recommender
        $adv = $$query->param('adv'); #advertiser
        #add to object
        $session->{'rc'} = $$query->param('rc');
        $session->{'adv'} = $$query->param('adv');
        $session->store();
        }
else
        {
        #get the session data for a returned visitor
        $sid = $$query->param('sid');
        $session = Apache::Session::DBI->open($sid);
        tie %session, 'Apache::Session::DBI', $sid;
        #checking if session has timed-out
        $rc = $session->{'rc'}; #recommender
        $adv = $session->{'adv'}; #advertiser
        }
&carry_on();
}

Well, this is about all of it. :)

If I take off those two lines everything is working fine and the 
sessions is added to the database.

Here's the complete error message from the error_log:

Session manager opening persistent connection at 
/usr/local/lib/site_perl/Apache/Session/DBI.pm line 40.
        Apache::Session::DBI::init_connection() called at 
/usr/local/lib/site_perl/Apache/Session/DBI.pm l
ine 206
        Apache::Session::DBI::fetch('Apache::Session::DBI', 
'351d62cfe6f5895f') called at /usr/local/lib/s
ite_perl/Apache/Session.pm line 61
        Apache::Session::open('Apache::Session::DBI', 
'351d62cfe6f5895f') called at lib/web/webmaster.pl l
ine 40
        WEBMASTER::main called at (eval 34) line 88
        Apache::ROOT::index_2epl::handler('Apache=SCALAR(0x82c6c78)') 
called at /usr/local/lib/site_perl/A
pache/Registry.pm line 135
        eval {...} called at 
/usr/local/lib/site_perl/Apache/Registry.pm line 135
        Apache::Registry::handler('Apache=SCALAR(0x82c6c78)') called 
at lib/web/printing.pl line 0
        eval {...} called at lib/web/printing.pl line 0
[Thu Mar 30 04:41:41 2000] [error] Can't call method "store" on 
unblessed reference at lib/web/webmaster.p
l line 54.

Reply via email to