[Catalyst] multiple sessions in one application w/ C::P::Session

Yuval Kogman nothingmuch at woobling.org
Wed Apr 26 20:07:59 CEST 2006


On Thu, Apr 27, 2006 at 03:31:12 +0900, Hideo Kimura wrote:
> Hi,
> 
> Thank you for your reply.
> 
> > Otherwise you could use the session for the long expiry, and then
> > simply reuse some of the session code, that I can refactor for you,
> > to create a session ID, etc, but actually store the data in your own
> > store that doesn't really care about expiring.
> 
> OK.  I can use this solution in the meantime.
> 
> But I think it is better, if I could use some namespaces to handle
> multiple sessions in one application.  I will appreciate you, if you
> think about it when you release next version of C::P::Session.

All the support is there - use the per-key expiry - you can wrap it
in your own sugar, but this is too much of a one-project feature for
me to generalize it properly.

You can use this code:

In YourApp:

	use Catalyst qw/
		Session
		Session::Store::Foo
		Session::State::Cookie

		+YourApp::Plugin::Session::TempPerm # Ovid++
	/;

	__PACKAGE__->config->{session}{expire} = $very_big_number; # don't expire
	__PACKAGE__->config->{session}{expire_temp} = $small_number; # TTL of temp

In YourApp::Plugin::Session::TempPerm;

	sub perm_session {
		my $c = shift;
		return $c->session;
	}

	sub temp_session {
		my $c = shift;
		$c->session_expire_key( $c->config->{session}{expire_temp});
		return $c->session->{temp_session_data};
	}

-- 
  Yuval Kogman <nothingmuch at woobling.org>
http://nothingmuch.woobling.org  0xEBD27418

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20060426/5921d5a7/attachment-0001.pgp 


More information about the Catalyst mailing list