nsISupports
Last changed in Gecko 1.9 (Firefox 3)See nsICookieManager
and nsICookieManager2
for methods to manipulate the cookie database directly. This separation of interface is mainly historical.
var cookieSvc = Components.classes["@mozilla.org/cookieService;1"] .getService(Components.interfaces.nsICookieService);
Notifications
This service broadcasts the following notifications when the cookie list is changed, or a cookie is rejected:
Topic | Subject | Data |
---|---|---|
|
Depending on the Data value, either an nsICookie2 interface pointer representing the cookie object that changed, or an nsIArray of nsICookie2 objects. |
A keyword indicating what was done to the affected cookie.
|
private-cookie-changed Since Firefox 20 (see bugzilla #837091) |
Same as cookie-changed , except used in lieu of cookie-changed for private windows. |
See cookie-changed . |
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. |
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); |
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. |
Methods
getCookieString()
Get the complete cookie string associated with the URI.
string getCookieString( in nsIURI aURI, in nsIChannel aChannel );
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.
Return value
Returns the resulting cookie string.
getCookieStringFromHttp()
Get the complete cookie string associated with the URI.
getCookieString()
will query the documentURI
property off of nsIHttpChannelInternal
if supported, so getCookieString()
can be used in place of this method.string getCookieStringFromHttp( in nsIURI aURI, in nsIURI aFirstURI, in nsIChannel aChannel );
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.
Return value
Returns the resulting cookie string.
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 );
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.
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 );
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.