Storing and retrieving cookies

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

Storing and retrieving cookies

ZuLuuuuuu-2
Hello,

Is there a sample for storing and retrieving cookies via Iliad? I've
found several methods for adding/reading cookies but couldn't put them
together :)

Canol
Reply | Threaded
Open this post in threaded view
|

Re: Storing and retrieving cookies

Nicolas Petton
Do you really need to store and retreive cookies?
Unless it's really necessary, I wouldn't do it. Iliad already adds a cookie with the session id, so maybe that's enough (the data can be stored and retreived from the session or an application)?

If not, you can retreive cookies with ILRequest>>cookies
The current request instance is available in applications and widgets with the #request method.

To store cookies, you can override #respondOn: in your applications:

MyApplication>>respondOn: aResponse [
     aResponse addCookie: aCookie. "instance of ILCookie"
     super respondOn: aResponse
]

HTH,
Nico

2010/6/4 ZuLuuuuuu <[hidden email]>
Hello,

Is there a sample for storing and retrieving cookies via Iliad? I've
found several methods for adding/reading cookies but couldn't put them
together :)

Canol

Reply | Threaded
Open this post in threaded view
|

Re: Storing and retrieving cookies

ZuLuuuuuu-2
On Jun 4, 9:05 pm, nicolas petton <[hidden email]> wrote:
> Do you really need to store and retreive cookies?
> Unless it's really necessary, I wouldn't do it. Iliad already adds a cookie
> with the session id, so maybe that's enough (the data can be stored and
> retreived from the session or an application)?
>

I just want to remember the member, for example, after one month. You
mean, I just need to make the expiration date of the session one month
after and store all the information in the application? That sounds
logical, actually.
Reply | Threaded
Open this post in threaded view
|

Re: Storing and retrieving cookies

Paolo Bonzini-2
On 06/04/2010 08:57 PM, ZuLuuuuuu wrote:
> I just want to remember the member, for example, after one month. You
> mean, I just need to make the expiration date of the session one month
> after and store all the information in the application? That sounds
> logical, actually.

That would eat a lot of memory and would be the perfect road to a denial
of service attack. :-)

Cookies are perfect for your usecase.

Paolo
Reply | Threaded
Open this post in threaded view
|

Re: Storing and retrieving cookies

sebastien audier
Yes, Paolo is right. For several reasons (mostly memory consumption), sessions in Iliad have a short expiration time (30 minutes by default). It means inactive sessions will expire after 30 minutes (again, this can be changed).

If means that all applications and widgets have the same short lifetime. Of course as long as a session is used, they will persist.

You can modify this expiration time, but to some extend only. If you need some client specific data to persist more than the lifetime of a session, you can use a cookie.

Cheers,
Seb