Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cookies API

18 views
Skip to first unread message

Jan Honza Odvarko

unread,
May 19, 2011, 1:39:12 AM5/19/11
to
What are the differencies between following API:

nsICookieManager2.add
nsICookieService.setCookieString
nsICookieService.setCookieStringFromHttp

Which API should be used for managing cookies (add new and modifying
an existing)?
Depends on a context and/or actual cookie values, which one should be
picked?

Honza

Ehsan Akhgari

unread,
May 19, 2011, 1:20:14 PM5/19/11
to Jan Honza Odvarko, dev-pl...@lists.mozilla.org
On 11-05-19 1:39 AM, Jan Honza Odvarko wrote:
> What are the differencies between following API:
>
> nsICookieManager2.add
> nsICookieService.setCookieString
> nsICookieService.setCookieStringFromHttp
>
> Which API should be used for managing cookies (add new and modifying
> an existing)?

It depends on the context, I think. If you're doing something in the
browser, you should probably use setCookieString(FromHttp) if you're
adding the cookie in the context of an HTTP transaction from within the
browser (and you get things like security checks and third-party cookie
checks), but nsICookieManager2::Add is a very direct way to create a
cookie and add it to the database, so it's more appropriate for a cookie
manager UI, for example.

> Depends on a context and/or actual cookie values, which one should be
> picked?

They're not different in that case. You can think of it this way:
setCookieString(FromHttp) are implemented in terms of Add (well, that's
not exactly true, but it's practically true for all intents and purposes.

Does this answer your question?

Ehsan

0 new messages