Class

NSHTTPCookie

A representation of an HTTP cookie.

Overview

An NSHTTPCookie object is immutable, initialized from a dictionary containing the attributes of the cookie. This class supports two different cookie versions:

  • Version 0: The original cookie format defined by Netscape.Most cookies are in this format.

  • Version 1: The cookie format defined in RFC 6265, HTTP State Management Mechanism.

Topics

Creating Cookies

cookiesWithResponseHeaderFields:forURL:

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

cookieWithProperties:

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

initWithProperties:

Initializes an HTTP cookie object with the given cookie properties.

Converting Cookies to Request Headers

requestHeaderFieldsWithCookies:

Converts an array of cookies to a dictionary of header fields.

Getting Cookie Host Properties

domain

The domain of the cookie.

path

The cookie’s path.

portList

The cookie’s port list.

Getting Cookie Metadata

name

The cookie’s name.

value

The cookie‘s string value.

version

The cookie’s version.

Determining Cookie Lifespan

expiresDate

The cookie’s expiration date.

sessionOnly

A Boolean value that indicates whether the cookie should be discarded at the end of the session (regardless of expiration date).

Securing Cookies

HTTPOnly

A Boolean value that indicates whether the cookie should only be sent to HTTP servers.

secure

A Boolean value that indicates whether this cookie should only be sent over secure channels.

Accessing Cookie Properties as Key-Value Pairs

properties

The cookie’s properties.

NSHTTPCookiePropertyKey

Constants that define the supported keys in a cookie attributes dictionary.

Getting User-Readable Cookie Metadata

comment

The cookie’s comment string.

commentURL

The cookie’s comment URL.

Accepting Cookies

NSHTTPCookieAcceptPolicy

Cookie acceptance policies implemented by the NSHTTPCookieStorage class.

Relationships

Inherits From

See Also

Cookies

NSHTTPCookieStorage

A container that manages the storage of cookies.