How to set/get cookies?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set/get cookies?

Tim Mackinnon
Hi - I’m trying to get back into seaside, and I’m trying to understand how you get/set cookies? I can see WACookie and WARequest has a #cookieAt: method - but I’m missing the key piece about where in your application lifecycle you can access these things to store for example a user preference (without going full hog with a database).

Tim
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How to set/get cookies?

Johan Brichau-2
Hi Tim,

Getting cookies, by accessing the WARequest instance from within your callback/rendering code:

        self requestContext request cookieAt: ‘myCookie'

Setting cookies, by accessing the WAResponse instance from within your rendering code:

        self requestContext response addCookie:
                (self requestContext newCookie
                                path:’/myApp';
                                key: ‘myCookie';
                                value: ‘myCookie').

Hope this puts you on your way!

Cheers
Johan

> On 3 May 2018, at 12:28, Tim Mackinnon <[hidden email]> wrote:
>
> Hi - I’m trying to get back into seaside, and I’m trying to understand how you get/set cookies? I can see WACookie and WARequest has a #cookieAt: method - but I’m missing the key piece about where in your application lifecycle you can access these things to store for example a user preference (without going full hog with a database).
>
> Tim
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How to set/get cookies?

Tim Mackinnon
Thanks - that #requestContext was the bit I was missing.

Is this documented anywhere obvious? I searched all over to find something and couldn't easily discover it. None of the tutorials dig into this, nor the Seaside book (I guess we could get it updated as I think seaside still has legs to it).

Possibly we could put a comment in WACookie - as I found it? Or maybe a more e2e test?

Tim

Sent from my iPhone

> On 3 May 2018, at 16:38, Johan Brichau <[hidden email]> wrote:
>
> Hi Tim,
>
> Getting cookies, by accessing the WARequest instance from within your callback/rendering code:
>
>    self requestContext request cookieAt: ‘myCookie'
>
> Setting cookies, by accessing the WAResponse instance from within your rendering code:
>
>    self requestContext response addCookie:
>        (self requestContext newCookie
>                path:’/myApp';
>                key: ‘myCookie';
>                value: ‘myCookie').
>
> Hope this puts you on your way!
>
> Cheers
> Johan
>
>> On 3 May 2018, at 12:28, Tim Mackinnon <[hidden email]> wrote:
>>
>> Hi - I’m trying to get back into seaside, and I’m trying to understand how you get/set cookies? I can see WACookie and WARequest has a #cookieAt: method - but I’m missing the key piece about where in your application lifecycle you can access these things to store for example a user preference (without going full hog with a database).
>>
>> Tim
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside