Re: [Catalyst] Session expiry per user

2008-03-14 Thread Matt Lawrence

Alexandre Jousset wrote:

Hello list,

I've problems to set session expiry time per user.

My goal is to have a default expiry time of until you quit the 
browser unless the user logs in and select a checkbox to have the 
site remember her (i.e. set expiry time to 1 year).


I use the following plugins for session management :

Session Session::State::Cookie Session::Store::DBI

I've looked at the docs and I've only found a way to set expiry 
time in MyApp.pm, and even with this I don't know how to set it for 
until you quit the brower. If I put 0 the session expires immediately.


To set the longer expiry time, I try:

$c-config-{session}{expires} = 31536000 if 
$c-req-param('remember_me');


I think that will make the cookie expire on the 1st January 1971. Try 
+31536000.


I have a feeling that an undef expiry will result in a session cookie, 
based on nothing more than guesswork and superstition.



Matt


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


Re: [Catalyst] Session expiry per user

2008-03-14 Thread Alexandre Jousset

Hello Matt,

Matt Lawrence a écrit :

To set the longer expiry time, I try:



I think that will make the cookie expire on the 1st January 1971. Try 
+31536000.


	Looking at the sessions table, the value is correct, with or without 
the '+'. The problem seems to come from the line :


 $c-config-{session}{expires} = 31536000 if
 $c-req-param('remember_me');

	that works only once. When I request another page on the site, the 
param 'remember_me' is not set so the sessions falls back to 1 hour (tha 
value I've put by default).


I have a feeling that an undef expiry will result in a session cookie, 
based on nothing more than guesswork and superstition.


Halas, 'undef' is like '0', the session expires immediately :-(

Regards,
--
--  \^/--
---/ O \-----
--   | |/ \|  Alexandre (Midnite) Jousset  |   --
---|___|-----

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


Re: [Catalyst] Session expiry per user

2008-03-14 Thread Matt Lawrence

Alexandre Jousset wrote:

Hello Matt,

Matt Lawrence a écrit :

To set the longer expiry time, I try:



I think that will make the cookie expire on the 1st January 1971. Try 
+31536000.


Looking at the sessions table, the value is correct, with or 
without the '+'. The problem seems to come from the line :


 $c-config-{session}{expires} = 31536000 if
 $c-req-param('remember_me');

that works only once. When I request another page on the site, the 
param 'remember_me' is not set so the sessions falls back to 1 hour 
(tha value I've put by default).


Ah, I missed the fact that you were accessing the cookies via a session 
plugin, I thought you were setting them directly.


Would it be horribly perverse to store the expiry interval time (or the 
remember_me bool) in the session?


$c-config-{session}{expires} = 31536000 if $c-session-{remember_me};

I have a feeling that an undef expiry will result in a session 
cookie, based on nothing more than guesswork and superstition.

Catatlyst::Plugin::Session::State::Cookie says:

  cookie_expires
  Number of seconds from now you want to elapse before cookie will
  expire.  Set to 0 to create a session cookie, ie one which 
will die

  when the user’s browser is shut down.


Matt

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


Re: [Catalyst] Session expiry per user

2008-03-14 Thread Bill Moseley
On Fri, Mar 14, 2008 at 12:33:19PM +0100, Alexandre Jousset wrote:
   Hello list,
 
   I've problems to set session expiry time per user.
 
   My goal is to have a default expiry time of until you quit the 
 browser unless the user logs in and select a checkbox to have the site 
 remember her (i.e. set expiry time to 1 year).

There's a plugin that is designed for that:

http://search.cpan.org/~nuffin/Catalyst-Plugin-Session-DynamicExpiry-0.02/lib/Catalyst/Plugin/Session/DynamicExpiry.pm

I'm not using it, but I looked at it in detail one day and had some
problems.  I think I posted a patch.  Yes, December 5th with the
subject Patch for Catalyst::Plugin::Session::DynamicExpiry

 $c-config-{session}{expires} = 31536000 if $c-req-param('remember_me');

That's per process.

-- 
Bill Moseley
[EMAIL PROTECTED]


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


Re: [Catalyst] Session expiry per user

2008-03-14 Thread Moritz Onken


Am 14.03.2008 um 13:53 schrieb Bill Moseley:


Catalyst::Plugin::Session::DynamicExpiry


isn't working for me using cookies. The patch was never applied so I  
go with this:


sub auto : Private {
my ( $self, $c ) = @_;
if ( $c-user_exists ) {
$c-config-{session}-{expires} = 
$c-session-{per_user_expiry}
  || $c-config-{session}-{expires};
$c-session_expires(1);
return 1;
}
}

set $c-session-{per_user_expiry} if you want a different expiry.
$c-session_expires(1) does all the stuff like setting cookies etc.

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


Re: [Catalyst] Session expiry per user

2008-03-14 Thread Alexandre Jousset

Hello Bill,

Bill Moseley a écrit :
	My goal is to have a default expiry time of until you quit the 
browser unless the user logs in and select a checkbox to have the site 
remember her (i.e. set expiry time to 1 year).


There's a plugin that is designed for that:

http://search.cpan.org/~nuffin/Catalyst-Plugin-Session-DynamicExpiry-0.02/lib/Catalyst/Plugin/Session/DynamicExpiry.pm

I'm not using it, but I looked at it in detail one day and had some
problems.  I think I posted a patch.  Yes, December 5th with the
subject Patch for Catalyst::Plugin::Session::DynamicExpiry


	You posted a patch against a version 0.03. On CPAN the version is 0.02. 
I googled to find the SVN but with no luck. Can you tell me where it is 
please?


	I've also found a Catalyst::Plugin::Session::DynamicExpiry::Cookie (not 
on CPAN) that does the job.


	I've spent a lot of time on it because Firefox *keeps session cookies* 
when you close all tabs and ask it to restore session on 
reopen.. Maybe it's FF that does this, maybe it's an extension, 
I don't know. The fact is that I've had to close the FF tab before the 
FF window in order to dismiss the cookie...


	I still have problems with the cookie TTL and the session TTL. With the 
module cited above, it does not seem to take into account my setting:


$c-session_time_to_live(31536000) if $c-req-param('rme');

	and instead use the default session TTL (2 hours, I see that in my 
`sessions` table).


	Maybe I'm mixing wrongly session TTL and cookie TTL but I thought 
$c-session_time_to_live(x) refered to session, not cookie. However it 
seems to refer to cookie.


	Anyway, with setting session TTL to 1 year, it now works as I want 
(maybe not as it should?).


Thanks a lot to you all!

PS : After some thinking I believe I start to understant it all ;-) but 
it's very confusing...

--
--  \^/--
---/ O \-----
--   | |/ \|  Alexandre (Midnite) Jousset  |   --
---|___|-----

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