2006-01-25

Added login for the Catalyst application

I tried to add login for my testing utility which is a Catalyst based web application last night. I finished the code by carefully following the examples provided with document. Not too bad, just a couple of lines and I was done. But the application complained:
Can't locate object method "session" via package "myapp" 
I went back and reviewed the code several times and could not figure out what was wrong. After hours of struggle, changing configurations, switching to different plugin modules, I finally got the reason. In my code, I used following statement to import several Catalyst plugins:
use Catalyst qw/Static::Simple  Session  Session::State::Cookie  Session::Store::File/;
use Catalyst qw/Authentication Authentication::Store::Minimal Authentication::Credential::Password/;

It seems that the later import (authentication related) overrode the previous import(session related). Thus the session method is missing because the module Session is not imported.

To fix this, just change the code to:
use Catalyst qw/-Debug Static::Simple Session
Session::State::Cookie Session::Store::File
Authentication Authentication::Store::Minimal
Authentication::Credential::Password
/;

No comments: