[Seaside] Cookies (again?)
avi at beta4.com
Sat May 15 21:22:53 CEST 2004
On May 15, 2004, at 11:28 AM, David Röthlisberger wrote:
>>> But what is the best way to _set_ cookie from the component? I've
>>> found "WAGenericResponse cookieAt: put:' and assume that I can add
>>> some code to WASession to use it, right?
>> Try something like this:
>> renderContentOn: html
>> html document cookieAt: 'foo' put: 'bar'.
> I'm in the same situation, but for me this piece of code doesn't work.
> I use
> the newest Seaside version for VW 7.2 (i.e. 2.5.15) and there "html
> document" (a WAHtmlStreamResponse) does not understand #cookieAt:put: .
Oh, you're right, actually, my mistake. I had thought that
WAHtmlStreamResponse inherited from WAGenericResponse, which has
#cookieAt:put:, but it doesn't. Try this for a quick fix:
- add a "cookies" ivar to WAHtmlStreamResponse
- override #cookies to return it:
^ cookies ifNil: [#()]
- implement #cookieAt:put: to use it:
cookieAt: key put: value
cookies ifNil: [cookies := Dictionary new].
^ cookies at: key put: value
In Squeak, that should work. In VW, I don't know if the underlying
support code that integrates with WebToolKit supports cookies yet.
More information about the Seaside