[Catalyst] Session trouble
Bill Moseley
moseley at hank.org
Mon Oct 8 16:19:59 GMT 2007
I noticed jrockway has fixed this in C::P::Session. Thanks!
Any idea when this might get pushed to CPAN?
BTW -- I had created a test case some time back. I'll attach it just
in case you want to add to the C::P::S::State::Cookie package.
On Thu, Aug 02, 2007 at 12:17:12PM -0700, Bill Moseley wrote:
> I'm still having plenty of session trouble. Maybe it's just related
> to the dev server.
>
> I'm implementing a "remember me", but once a cookie is written (rather
> is returned in the request) a new cookie is never sent.
>
> Is there a way to force a cookie?
>
> No, Session::DynamicExpiry doesn't help.
>
> Also, and this is weird, when a cookie is supplied by the browser
> besides the Session plugins not sending a cookie, the cookie still
> gets setup but *after* the headers have already been sent.
>
> In Engine::HTTP I added the warn line below:
>
> if ( my $headers = delete $self->{_header_buf} ) {
> DEBUG && warn "write: Wrote headers and first chunk (" . length($headers . $buffer) . " bytes)\n";
> $ret = $self->NEXT::write( $c, $headers . $buffer );
>
> warn $headers, time, "\n"; sleep 2; # WARN DEBUG
> }
>
> Then in a test application I have:
>
> sub calculate_session_cookie_expires {
> my $c = shift;
>
> warn "in calculate_session_cookie_expires ", time, "\n"; sleep 1;
>
> return time + 10;
> }
>
> Then I see that calculate_session_cookie_expires is called after the
> headers have already been written:
>
> HTTP/1.0 200 OK
> Connection: close
> Date: Thu, 02 Aug 2007 19:09:53 GMT
> Content-Length: 15
> Status: 200
>
> 1186081793
> in calculate_session_cookie_expires 1186081795
>
>
>
>
> Here's an entire test application:
>
> package Foo;
> use strict;
> use warnings;
> use Catalyst::Runtime;
> use Catalyst (
> 'Session',
> 'Session::State::Cookie',
> 'Session::Store::FastMmap',
> 'Cache::FastMmap',
> # 'Session::DynamicExpiry',
> );
> __PACKAGE__->config( name => 'Foo' );
> __PACKAGE__->setup;
>
>
> sub default : Private {
> my ( $self, $c ) = @_;
> $c->res->body( 'setting session' );
> $c->session->{bar} = time; # Trigger session write
> }
>
>
>
> sub calculate_session_cookie_expires {
> my $c = shift;
>
> warn "in calculate_session_cookie_expires ", time, "\n"; sleep 1;
>
> return time + 10;
> }
>
> 1;
--
Bill Moseley
moseley at hank.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: update_cookie.t
Type: application/x-troff
Size: 2942 bytes
Desc: not available
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071008/6936f894/update_cookie.t
More information about the Catalyst
mailing list