[Seaside] Cookies (again?)

Avi Bryant avi at beta4.com
Sun May 16 22:50:27 CEST 2004

On May 16, 2004, at 6:50 AM, David Röthlisberger wrote:

> For my purpose it is a little bit cumbersome to use HtmlStreamResponse 
> to
> set a cookie, because I have a login form, then a user clicks on the
> 'login'-button, so the corresponding method #login is called, where I 
> check
> user's nick and password and set a cookie. Afterwards I would like to 
> call
> WAComponent>>answer, so there won't be any html response from the
> Login-Component. Now I had to render again the login-component, so I 
> was
> able to set the cookie using HtmlStreamResponse. But it would be more
> convenient if it would be also possible to set a cookie before calling
> WAComponent>>answer or WAComponent>>call, then this cookie could be 
> appended
> to the RedirectResponse (or something else).

That's a good point.  It would be pretty easy to add a set of 
#redirectWithCookie:... methods to WASession, eg,

	self loginIsSuccessful ifTrue:
		[self session redirectWithCookie: 'username' value: self username 
expiry: (DateAndTime now + 1 hour).
		self answer: true]

So you'd force a redirect that sets the cookie and then comes right 
back.  Also useful would be #checkForCookies - this would send back a 
redirect response with a random cookie with short expiry, and then 
check for it on the request:

[self session checkForCookies] whileFalse:
	[self inform: 'Cookies must be enabled to proceed.']

Patches implementing this are welcome; otherwise I'll get around to it 
soon enough.


More information about the Seaside mailing list