[Catalyst] Authentication and session

Bill Moseley moseley at hank.org
Mon Mar 20 06:52:21 CET 2006


On Mon, Mar 20, 2006 at 12:44:16PM +0800, fayland wrote:
> We have a checkbox "Keep me logged in" when the user login. the problem 
> is how to approach it?
> it seems that $c->login( $user, $password ) doesn't have any option to 
> set the session cookie. and Session::State::Cookie has a option 
> "cookie_expires", but how can I set it to the session cookie?

Not sure if this is the best way, but I provide a way to enable
session cookies via a checkbox.  So I override finailize_cookies:


    # Use a non-persistent cookie if login_temp was checked
    local $c->config->{session}{cookie_expires} = 0
        if $c->session->{session_cookie};


    $c->NEXT::finalize_cookies( @_ );

where the "session_cookie" is my flag set in my login action.

I don't really use that code as I've moved to always using session
cookies for login.

-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list