Class

NSHTTPCookie

An NSHTTPCookie object represents an HTTP cookie. It is an immutable object, initialized from a dictionary containing the cookie attributes.

Overview

The NSHTTPCookie class supports two different cookie versions:

  • Version 0: This version refers to “traditional” or “old-style” cookies, the original cookie format defined by Netscape. The majority of cookies encountered are in this format.

  • Version 1: This version refers to cookies as defined in RFC 2965, HTTP State Management Mechanism.

Topics

Create cookie instances

cookiesWithResponseHeaderFields:forURL:

Returns an array of NSHTTPCookie objects corresponding to the provided response header fields for the provided URL.

cookieWithProperties:

Creates and initializes an NSHTTPCookie object using the provided properties.

initWithProperties:

Returns an initialized NSHTTPCookie object using the provided properties.

Convert cookies to request headers

requestHeaderFieldsWithCookies:

Returns a dictionary of header fields corresponding to a provided array of cookies.

Getting cookie properties

comment

The receiver's comment string.

commentURL

The receiver’s comment URL.

domain

The domain of the receiver’s cookie.

expiresDate

The receiver’s expiration date.

HTTPOnly

A boolean value that indicates whether the receiver should only be sent to HTTP servers per RFC 2965.

secure

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

sessionOnly

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

name

The receiver’s name.

path

The receiver’s path.

portList

The receiver's port list.

properties

The receiver’s cookie properties.

value

The receiver’s value.

version

The receiver’s version.

Constants

NSHTTPCookiePropertyKey

These constants define the supported keys in a cookie attributes dictionary.

NSHTTPCookieAcceptPolicy

NSHTTPCookieAcceptPolicy specifies the cookie acceptance policies implemented by the NSHTTPCookieStorage class.

Relationships

Inherits From

See Also

Setting Cookie Policies

HTTPCookieAcceptPolicy

A policy constant that determines when cookies should be accepted.

HTTPShouldSetCookies

A Boolean value that determines whether requests should contain cookies from the cookie store.

HTTPCookieStorage

The cookie store for storing cookies within this session.

NSHTTPCookieStorage

NSHTTPCookieStorage implements a singleton object (shared instance) that manages storage of cookies. Each cookie is represented by an instance of the NSHTTPCookie class. As a rule, cookies are shared among all applications and are kept in sync across process boundaries. Session cookies (where the cookie object’s sessionOnly method returns YES) are local to a single process and are not shared.