Type Method

cookieWithProperties:

Creates and initializes an HTTP cookie object using the provided properties.

Declaration

+ (NSHTTPCookie *)cookieWithProperties:(NSDictionary<NSHTTPCookiePropertyKey, id> *)properties;

Parameters

properties

The properties for the new cookie object, expressed as key value pairs.

Return Value

The newly created cookie object. Returns nil if the provided properties are invalid.

Discussion

To successfully create a cookie, you must provide values for (at least) the NSHTTPCookiePath, NSHTTPCookieName, and NSHTTPCookieValue keys, and either the NSHTTPCookieOriginURL key or the NSHTTPCookieDomain key.

See Accepting Cookies for more information on the available cookie attribute constants and the constraints imposed on the values in the dictionary.

See Also

Creating Cookies

+ cookiesWithResponseHeaderFields:forURL:

Creates an array HTTP cookies corresponding to the provided response header fields for the provided URL.

- initWithProperties:

Initializes an HTTP cookie object with the given cookie properties.