# NSHTTPCookie class documentation

rfm@gnu.org
Generated at 2025-12-02 21:52:00 +0000
2006 Software Foundation, Inc.
Software documentation for the NSHTTPCookie class
Foundation/NSHTTPCookie.h
An instance of the NSHTTPCookie class is a single, immutable http cookie. It can be initialised with properties from a dictionary and has accessor methods to obtain the cookie values.
The class supports unversioned cookies (sometimes referred to as version 0) as originally produced by netscape, as well as more recent standardised and versioned cookies.
cookieWithProperties:
properties
Allocates and returns an autoreleasd instance using -initWithProperties: to initialise it from properties.
cookiesWithResponseHeaderFields:
headerFields
forURL:
URL
Returns an array of cookies parsed from the headerFields and URL (assuming that the headerFields came from a response to a request sent to the URL).
The headerFields dictionary must contain at least all the headers relevant to cookie setting... other headers are ignored.
requestHeaderFieldsWithCookies:
cookies
Returns a dictionary of header fields that can be used to add the specified cookies to a request.
comment
Returns a string which may be used to describe the cookie to the user, or `nil` if no comment is set.
commentURL
Returns a URL where the user can find out about the cookie, or `nil` if no comment URL is set.
domain
Returns the domain to which the cookie should be sent.
If there is a leading dot then subdomains should also receive the cookie as specified in RFC 2965.
expiresDate
Returns the expiry date of the receiver or `nil` if there is no such date.
initWithProperties:
properties
Initialises the receiver with a dictionary of properties.
Unrecognised keys are ignored.
Returns `nil` if a required key is missing or if an illegal value is specified for a key.
NSHTTPCookieComment
The NSString comment for the cookie (if any).
This is `nil` by default and for unversioned cookies.
NSHTTPCookieCommentURL
The NSString or NSURL URL to get the comment for the cookie.
This is `nil` by default and for unversioned cookies.
NSHTTPCookieDomain
The NSString specified the domain to which the cookie applies.
This is extracted from NSHTTPCookieOriginURL if not specified.
NSHTTPCookieDiscard
A NSString (either TRUE or FALSE) saying whether the cookie is to be discarded when the session ends.
Defaults to FALSE except for versioned cookies where NSHTTPCookieMaximumAge is unspecified.
NSHTTPCookieExpires
The NSDate or NSString(format Wdy, DD-Mon-YYYY HH:MM:SS GMT) specifying when an unversioned cookie expires and ignored for versioned cookies.
NSHTTPCookieMaximumAge
An NSStringcontaining an integer value specifying the longest time (in seconds) for which the cookie is valid.
This defaults to zero and is only meaningful for versioned cookies.
NSHTTPCookieName
An NSString... obvious... no default value.
NSHTTPCookieOriginURL
An NSString or NSURLspecifying the URL which set the cookie.
Must be supplied if NSHTTPCookieDomain is not.
NSHTTPCookiePath
An NSStringspecifying the path from the cookie.
If unspecified this value is determined from NSHTTPCookieOriginURL or defaults to '/'.
NSHTTPCookiePort
An NSStringcontaining a comma separated list of integer port numbers. This is valid for versioned cookies and defaults to an empty string.
NSHTTPCookieSecure
An NSStringsaying whether the cookie may be sent over insecure connections.
The default is FALSE meaning that it may be sent insecurely.
NSHTTPCookieValue
An NSStringcontaining the whole value of the cooke.
This parameter must be provided.
NSHTTPCookieVersion
An NSStringspecifying the cookie version... for an unversioned cookie (the default) this is '0'.
Also supports version '1'.
isHTTPOnly
Description forthcoming.
isSecure
Description forthcoming.
isSessionOnly
Description forthcoming.
name
Returns the name of the receiver.
path
Returns the URL path within the cookie's domain for which this cookie must be sent.
portList
Returns the list of ports to which the receiver should be sent, or `nil` if the cookie can be used for any port.
properties
Returns a dictionary representation of the receiver which could be used as the argument for -initWithProperties: to recreate a copy of the receiver.
value
Returns the value of the receiver.
version
Returns 0 for an unversioned Netscape style cookie or a positive integer for a versioned cookie.