Re: [Catalyst] Session trouble

2007-08-02 Thread Bill Moseley
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
[EMAIL PROTECTED]


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Session trouble

2007-07-23 Thread Jim Spath

Bill Moseley wrote:

On Mon, Jul 16, 2007 at 07:20:36PM +0300, Yuval Kogman wrote:

Hi,

no update yet, been terribly busy (the client is not being very nice
to us).

If you need comaint to release yourself let me know. You should have
commit access, right?


I can take another stab at it -- I had spent a few hours throwing
warn and cluck messages into the code to try and figure out what was
going on.  My eyes started to glaze over after a while.

I like how you refactored the plugins quite a bit.  But, I wish there
were comments in the code to give a little context.  That would make
debugging by people unfamiliar with the code easier.  I also find NEXT
makes it a bit more complicated when trying to follow stack traces.

Would you have a few minutes to at least verify if you can reproduce
the problem with the test application I sent?  I'd like to rule out any
thing that might be due to my environment.


What seems to be happening (and this was happening with a previous bit
of code from a week or two back) was that I was accessing the session
after it had been cleared/reset at the end of finalize (or something
like that).  So, that was creating a new sessionid and thus storing
the session data under a different id than the id used in the cookie.

This is the code that's getting me now:

sub calculate_session_cookie_expires {
my $c = shift;

return $c-session-{remember_me}
? $c-session_expires
: $c-NEXT::calculate_session_cookie_expires;
}

I think the quick fix would be to stuff the remember_me flag in the
stash earlier in the request and look at the stash instead of the
session (to avoid creating a new sessionid by calling $c-session).

I thought it might be a matter or moving
$c-_clear_session_instance_data later in the request cycle, but it
seems that's not really the problem.  I was seeing multiple sessions
created (and cleared) in the case of a request with a cookie with an
id for an expired session -- which doesn't seem right.


Oh, and to note again:  I think the behavior of dieing on invalid
session id format is not right.  The id should just be ignored in that
case and a new cookie sent.  If someone ends up with a bad cookie (or
the cookie format changes) could result in a lockout.


Hi,

We recently upgraded our Session modules and 
C::P::Session::DynamicExpiry no longer seems to function.


I was wondering if this could be related to the issues discussed in this 
email thread?


If so, is there any update?  If not, is some temporary way for me to get 
remember me functionality working again?


Thanks!
- Jim

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Session trouble

2007-07-16 Thread Yuval Kogman
Hi,

no update yet, been terribly busy (the client is not being very nice
to us).

If you need comaint to release yourself let me know. You should have
commit access, right?

The upload from today was to fix the test that needs Cookie.

-- 
  Yuval Kogman [EMAIL PROTECTED]
http://nothingmuch.woobling.org  0xEBD27418


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Session trouble

2007-07-16 Thread Bill Moseley
On Mon, Jul 16, 2007 at 07:20:36PM +0300, Yuval Kogman wrote:
 Hi,
 
 no update yet, been terribly busy (the client is not being very nice
 to us).
 
 If you need comaint to release yourself let me know. You should have
 commit access, right?

I can take another stab at it -- I had spent a few hours throwing
warn and cluck messages into the code to try and figure out what was
going on.  My eyes started to glaze over after a while.

I like how you refactored the plugins quite a bit.  But, I wish there
were comments in the code to give a little context.  That would make
debugging by people unfamiliar with the code easier.  I also find NEXT
makes it a bit more complicated when trying to follow stack traces.

Would you have a few minutes to at least verify if you can reproduce
the problem with the test application I sent?  I'd like to rule out any
thing that might be due to my environment.


What seems to be happening (and this was happening with a previous bit
of code from a week or two back) was that I was accessing the session
after it had been cleared/reset at the end of finalize (or something
like that).  So, that was creating a new sessionid and thus storing
the session data under a different id than the id used in the cookie.

This is the code that's getting me now:

sub calculate_session_cookie_expires {
my $c = shift;

return $c-session-{remember_me}
? $c-session_expires
: $c-NEXT::calculate_session_cookie_expires;
}

I think the quick fix would be to stuff the remember_me flag in the
stash earlier in the request and look at the stash instead of the
session (to avoid creating a new sessionid by calling $c-session).

I thought it might be a matter or moving
$c-_clear_session_instance_data later in the request cycle, but it
seems that's not really the problem.  I was seeing multiple sessions
created (and cleared) in the case of a request with a cookie with an
id for an expired session -- which doesn't seem right.


Oh, and to note again:  I think the behavior of dieing on invalid
session id format is not right.  The id should just be ignored in that
case and a new cookie sent.  If someone ends up with a bad cookie (or
the cookie format changes) could result in a lockout.

Thanks,

-- 
Bill Moseley
[EMAIL PROTECTED]


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/