[Catalyst] Session trouble
Bill Moseley
moseley at hank.org
Thu Aug 2 20:17:12 GMT 2007
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
More information about the Catalyst
mailing list