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

I'm using CGI::Session, CGI::Application and CGI::Application::Plugin::Session. I am storing an object reference in a CGI session parameter. I then retrieve the object reference from the CGI session. However, when I try to call methods that are defined for the object reference, I receive an error "can't locate object method x via package y". Here's the basic code I'm using:
$ball = Ballsearch->new; $ball->findball; # Works fine # Creates new object using CGI::Application::Plugin::Session my $session = $self->session; $session->param("ball", $ball); $ball = $self->session->param("ball"); print ref($ball); # Prints: Ballsearch $ball->findball; # Error: Can't locate object method find via packag +e Ballsearch $ball->Ballsearch::findball; # This works
Thanks in advance!

Replies are listed 'Best First'.
Re: CGI Session
by arcnon (Monk) on Oct 03, 2007 at 16:39 UTC
    $ball = $self->session->param("ball");

    $ball = $session->param("ball");
    you made $session your ref to the object so your are trying to access it the wrong way