[Catalyst-dev] Session module

jackal me at jackal.in
Thu Nov 20 10:14:03 GMT 2008


On Thursday 13 November 2008 00:15:58 Matt S Trout wrote:
> On Mon, Oct 20, 2008 at 03:49:40PM +0400, jackal wrote:
> > Hello,
> >
> > This is proposal for a new module, similar to
> > Catalyst::Plugin::Session::DynamicExpiry.
> >
> > The difference is, that my module can handle cookie expiring, but not
> > only session. It's necessary for implementing features like "remember me"
> > checkboxes fully.
> >
> > It's not seemed necessary to inherit the basic module, cause it's rather
> > simple and I think 'all-in-one' solution is more convenient.
>
> Only for new code. Not for people trying to update existing code who
> already rely on the current store and state plugins.
>
> Try again.

I don't know any existing code which can handle cookie expiring.
So I can add a compatibility shim like this:

sub session_time_to_live {
    my ( $c, $ttl ) = @_;
    if (defined $ttl) {
        $c->session_cookie_ttl($ttl);
        $c->session_ttl($ttl) if $ttl > 0; # maybe 'session' cookie w/o expiry
    }
    # Choose a smaller value if there's not a 'session' cookie
    my ($st, $ct) = ($c->session_ttl, $c->cookie_ttl);
    return ( ($ct < $st) && ($ct > 0) ) ? $ct : $st;
}

It implements DynamicExpiry's public method and handle cookie expiring 
automatically, based on session expiring.


-- 
Kind regards, Eugeny.



More information about the Catalyst-dev mailing list