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
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