[Seaside] Session expiry

Amos aaamos at gmail.com
Thu Jan 3 07:36:58 UTC 2008


> > Override #handleExpiredRequest: in WAApplication.
>
> Brilliant, exactly what I was looking for. Hopefully I'll have more
> time to try it out tomorrow - thanks for your time and patience with
> an impatient Seaside newbie :-)
>

Gruezi (hope I got that right...) Lukas,

Would the following approach (or something along those lines) makes sense?

-----

1) Add a method to WAComponent class:

expiryPathFor: aRequest
	"Answer nil by default (this will let WAApplication>>expiryPathFor: handle
	the expired request; see this method for more details. Override to provide
	a custom URL for expired sessions."

	^nil

2) Override WARegistry>>expiryPathFor: on WAApplication:

expiryPathFor: aRequest
	"Check whether my root component class overrides this method. If so, use its
	value; otherwise, use the default supplied by my superclass."

	^(self rootComponent expiryPathFor: aRequest)
		ifNil: [super expiryPathFor: aRequest]

Then, if an application wants to, it could simply do something like
this in its root component:

expiryPathFor: aRequest
	"Overrides default to provide a custom URL for expired sessions."

	^aRequest url, '/sessionExpired'

-----

(I haven't checked whether the URL can contain parameters, obviously
that would have to be handled if it does, but the idea remains the
same.)

I'd also prefer to get the session instance rather than just the root
component class, but haven't yet discovered how to do that from
WAApplication (is there a way?). With the method from 1) moved from
the component class to the session instance, I'd be able to override
this in my custom session class and make the session expiry behaviour
dependent on whether or not a user is logged in and/or other factors.

Cheers,

Amos


More information about the seaside mailing list