The nsICookieManager2
interface contains additional methods that expand upon the nsICookieManager
interface.
Inherits from: nsICookieManager
This interface is included in The Services.jsm
JavaScript code module. To create an object implementing this interface:
Components.utils.import("resource://gre/modules/Services.jsm");
var cookieService = Services.cookies;
void add(in AUTF8String aHost, in AUTF8String aPath, in ACString aName, in ACString aValue, in boolean aIsSecure, in boolean aIsHttpOnly, in boolean aIsSession, in PRInt64 aExpiry); |
boolean cookieExists(in nsICookie2 aCookie); |
unsigned long countCookiesFromHost(in AUTF8String aHost); |
boolean findMatchingCookie(in nsICookie2 aCookie, out unsigned long aCountFromHost); Obsolete since Gecko 1.9 |
nsISimpleEnumerator getCookiesFromHost(in AUTF8String aHost); |
void importCookies(in nsIFile aCookieFile); |
Adds a cookie. nsICookieService
is the normal way to do this. This method is something of a back door.
void add( in AUTF8String aHost, in AUTF8String aPath, in ACString aName, in ACString aValue, in boolean aIsSecure, in boolean aIsHttpOnly, in boolean aIsSession, in PRInt64 aExpiry );
aHost
aPath
aName
aValue
aIsSecure
true
if the cookie should only be sent over a secure connection.aIsHttpOnly
true
if the cookie should only be sent to, and can only be modified by, an HTTP connection.aIsSession
true
if the cookie should exist for the current session only.aExpiry
aIsSession
is false
.Returns whether or not a matching cookie already exists.
boolean cookieExists( in nsICookie2 aCookie );
aCookie
Returns true
if a cookie was found which matches the host, path, and name fields of aCookie
.
Returns the number of cookies that would be returned to a given host.
This ignores the cookie flags isDomain
, isSecure
, and isHttpOnly
. Therefore, if the specified host is "weather.yahoo.com", host or domain cookies for "weather.yahoo.com" and "yahoo.com" would both be counted, while a cookie for "my.weather.yahoo.com" would not.
unsigned long countCookiesFromHost( in AUTF8String aHost );
aHost
The number of matching cookies found.
Find whether a matching cookie already exists, and how many cookies a given host has already set. This is useful when e.g. prompting the user whether to accept a given cookie.
boolean findMatchingCookie( in nsICookie2 aCookie, out unsigned long aCountFromHost );
aCookie
aCountFromHost
true
if a cookie was found which matches the host, path, and name fields of aCookie.
Returns an enumerator of cookies that would be returned to a given host, ignoring the cookie flags isDomain
, isSecure
, and isHttpOnly
. Therefore, if the specified host is "weather.yahoo.com", host or domain cookies for "weather.yahoo.com" and "yahoo.com" would both be returned, while a cookie for "my.weather.yahoo.com" would not.
nsISimpleEnumerator getCookiesFromHost( in AUTF8String aHost );
aHost
An nsISimpleEnumerator
of nsICookie2
objects representing the matching cookies.
Imports an old-style cookie file. The imported cookies will be added to the existing cookie database. If the database contains any cookies that are the same as those being imported (that is, they have the same domain, name, and path), they are replaced with the ones being imported.
void importCookies( in nsIFile aCookieFile );
aCookieFile
cookies.txt
.