nsICookieService
From MDC
The nsICookieService interface provides methods for setting and getting cookies in the context of a page load. See nsICookieManager and nsICookieManager2 for methods to manipulate the cookie database directly. This separation of interface is mainly historical.
[edit] Notifications
This service broadcasts the following notifications when the cookie list is changed, or a cookie is rejected:
| Topic | Subject | Data |
|---|---|---|
| cookie-changed
Broadcast whenever the cookie list changes in some way. There are four possible data strings for this notification; one notification will be broadcast for each change, and will involve a single cookie. | An nsICookie2 interface pointer representing the cookie object that changed.
| A keyword indicating what was done to the affected cookie.
|
| cookie-rejected
Broadcast whenever the user's preferences cause a cookie to be rejected from being set. | An nsIURI interface pointer representing the URI that attempted to set the cookie.
| None. |
Contents |
nsICookieService is defined in netwerk/cookie/public/nsICookieService.idl. It is scriptable and
unfrozen (hasn't changed since Mozilla 1.9).
Inherits from: nsISupports
[edit] Method overview
string getCookieString(in nsIURI aURI, in nsIChannel aChannel);
|
string getCookieStringFromHttp(in nsIURI aURI, in nsIURI aFirstURI, in nsIChannel aChannel);
|
void setCookieString(in nsIURI aURI, in nsIPrompt aPrompt, in string aCookie, in nsIChannel aChannel);
|
void setCookieStringFromHttp(in nsIURI aURI, in nsIURI aFirstURI, in nsIPrompt aPrompt, in string aCookie, in string aServerTime, in nsIChannel aChannel);
|
[edit] Attributes
| Attribute | Type | Description |
cookieIconIsVisible
| boolean
| This attribute really doesn't belong on this interface. CVS blame will tell you why it is here. It remains until we can find a better home for it. |
[edit] Methods
[edit] getCookieString()
Get the complete cookie string associated with the URI.
string getCookieString( in nsIURI aURI, in nsIChannel aChannel );
[edit] Parameters
- aURI
- The URI of the document for which cookies are being queried.
- aChannel
- The channel used to load the document. this parameter may be null, but it is strongly recommended that a non-null value be provided to ensure that the cookie privacy preferences are honored.
[edit] Return value
Returns the resulting cookie string.
[edit] getCookieStringFromHttp()
Get the complete cookie string associated with the URI.
getCookieString() will query the documentURI property off of nsIHttpChannelInternal if supported, so tetCookieString() can be used in place of this method.string getCookieStringFromHttp( in nsIURI aURI, in nsIURI aFirstURI, in nsIChannel aChannel );
[edit] Parameters
- aURI
- The URI of the document for which cookies are being queried.
- aFirstURI
- The URI that the user originally typed in or clicked on to initiate the load of the document referenced by
aURI.
- aChannel
- The channel used to load the document. this parameter may be null, but it is strongly recommended that a non-null value be provided to ensure that the cookie privacy preferences are honored.
[edit] Return value
Returns the resulting cookie string.
[edit] setCookieString()
Set the cookie string associated with the URI.
aPrompt, since nsIPrompt can be queried from aChannel.void setCookieString( in nsIURI aURI, in nsIPrompt aPrompt, in string aCookie, in nsIChannel aChannel );
[edit] Parameters
- aURI
- The URI of the document for which cookies are being queried.
- aPrompt
- The prompt to use for all user-level cookie notifications.
- aCookie
- The cookie string to set.
- aChannel
- The channel used to load the document. this parameter may be null, but it is strongly recommended that a non-null value be provided to ensure that the cookie privacy preferences are honored.
[edit] setCookieStringFromHttp()
Set the cookie string and expires associated with the URI.
setCookieString() will query the documentURI property off of nsIHttpChannelInternal if supported, and setCookieString() could also query the Date header from the channel if aChannel supports nsIHttpChannel.void setCookieStringFromHttp( in nsIURI aURI, in nsIURI aFirstURI, in nsIPrompt aPrompt, in string aCookie, in string aServerTime, in nsIChannel aChannel );
[edit] Parameters
- aURI
- The URI of the document for which cookies are being queried.
- aFirstURI
- The URI that the user originally typed in or clicked on to initiate the load of the document referenced by aURI.
- aPrompt
- The prompt to use for all user-level cookie notifications.
- aCookie
- The cookie string to set.
- aServerTime
- The expiry information of the cookie (the Date header from the HTTP response).
- aChannel
- The channel used to load the document. this parameter may be null, but it is strongly recommended that a non-null value be provided to ensure that the cookie privacy preferences are honored.