Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSHTTPCookieMBS class.

NSHTTPCookieMBS.cookiesWithResponseHeaderFields(headerFields as dictionary, URL as string) as NSHTTPCookieMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns an array of NSHTTPCookie objects corresponding to the provided response header fields for the provided URL.

headerFields: The header fields used to create the NSHTTPCookie objects.
URL: The URL associated with the created cookies.

Returns the array of created cookies.

This method ignores irrelevant header fields in headerFields, allowing dictionaries to contain additional data.

If headerFields does not specify a domain for a given cookie, the cookie is created with a default domain value of theURL.

If headerFields does not specify a path for a given cookie, the cookie is created with a default path value of "/".

NSHTTPCookieMBS.cookieWithProperties(dic as dictionary) as NSHTTPCookieMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Creates and initializes an NSHTTPCookie object using the provided properties.
Example
// create dictionary with properties:
dim prop as new Dictionary
dim d as new date
d.Year = d.Year + 1

prop.Value(NSHTTPCookieMBS.NSHTTPCookieVersion)="0"
prop.Value(NSHTTPCookieMBS.NSHTTPCookieName)="test"
prop.Value(NSHTTPCookieMBS.NSHTTPCookieValue)="some value"
prop.Value(NSHTTPCookieMBS.NSHTTPCookieOriginURL)="http://www.mbsplugins.de/"
prop.Value(NSHTTPCookieMBS.NSHTTPCookieDomain)="www.mbsplugins.de"
prop.Value(NSHTTPCookieMBS.NSHTTPCookiePath)="/"
prop.Value(NSHTTPCookieMBS.NSHTTPCookieExpires)=d

// create cookie from properties
dim cookie as NSHTTPCookieMBS = NSHTTPCookieMBS.cookieWithProperties(prop)

// and display properties
dim dic as Dictionary = cookie.properties
dim list(-1) as string

for each key as Variant in dic.keys
List.Append key.StringValue+": "+dic.Value(key).StringValue
next

MsgBox Join(list,EndOfLine)

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

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

See NSHTTPCookie* shared method for more information on the available header field constants and the constraints imposed on the values in the dictionary.

NSHTTPCookieMBS.NSHTTPCookieComment as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String containing the comment for the cookie.
Only valid for Version 1 cookies and later. This header field is optional.

NSHTTPCookieMBS.NSHTTPCookieCommentURL as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String containing the comment URL for the cookie.
Only valid for Version 1 cookies or later. This header field is optional.

NSHTTPCookieMBS.NSHTTPCookieDiscard as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String stating whether the cookie should be discarded at the end of the session.
String value must be either "TRUE" or "FALSE". This header field is optional. Default is "FALSE", unless this is cookie is version 1 or greater and a value for NSHTTPCookieMaximumAge is not specified, in which case it is assumed "TRUE".

NSHTTPCookieMBS.NSHTTPCookieDomain as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String containing the domain for the cookie.
A value must be specified for either NSHTTPCookieDomain or NSHTTPCookieOriginURL. If this header field is missing the domain is inferred from the value for NSHTTPCookieOriginURL.

NSHTTPCookieMBS.NSHTTPCookieExpires as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An Date object or String specifying the expiration date for the cookie.
This header field is only used for Version 0 cookies. This header field is optional.

NSHTTPCookieMBS.NSHTTPCookieMaximumAge as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String containing an integer value stating how long in seconds the cookie should be kept, at most.
Only valid for Version 1 cookies and later. Default is "0". This field is optional.

NSHTTPCookieMBS.NSHTTPCookieName as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String object containing the name of the cookie. This field is required.

NSHTTPCookieMBS.NSHTTPCookieOriginURL as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String containing the URL that set this cookie.
A value must be specified for either NSHTTPCookieDomain or NSHTTPCookieOriginURL.

NSHTTPCookieMBS.NSHTTPCookiePath as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String containing the path for the cookie. This field is required if you are using the NSHTTPCookieDomain key instead of the NSHTTPCookieOriginURL key.
If you are using the NSHTTPCookieOriginURL key, the path is inferred if it is not provided. The default value is "/".

NSHTTPCookieMBS.NSHTTPCookiePort as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String containing comma-separated integer values specifying the ports for the cookie.
Only valid for Version 1 cookies or later. The default value is an empty string (""). This header field is optional.

NSHTTPCookieMBS.NSHTTPCookieSecure as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String indicating that the cookie should be transmitted only over secure channels.
Providing any value for this key indicates that the cookie should remain secure.

NSHTTPCookieMBS.NSHTTPCookieValue as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String containing the value of the cookie.
This header field is required.

NSHTTPCookieMBS.NSHTTPCookieVersion as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
One of the dictionary constants for cookies.

An String that specifies the version of the cookie.
Must be either "0" or "1". The default is "0". This header field is optional.

NSHTTPCookieMBS.requestHeaderFieldsWithCookies(cookies() as NSHTTPCookieMBS) as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns a dictionary of header fields corresponding to a provided array of cookies.
Example
// create dictionary with properties:
dim prop as new Dictionary
dim d as new date
d.Year = d.Year + 1

prop.Value(NSHTTPCookieMBS.NSHTTPCookieVersion)="0"
prop.Value(NSHTTPCookieMBS.NSHTTPCookieName)="test"
prop.Value(NSHTTPCookieMBS.NSHTTPCookieValue)="some value"
prop.Value(NSHTTPCookieMBS.NSHTTPCookieOriginURL)="http://www.mbsplugins.de/"
prop.Value(NSHTTPCookieMBS.NSHTTPCookieDomain)="www.mbsplugins.de"
prop.Value(NSHTTPCookieMBS.NSHTTPCookiePath)="/"
prop.Value(NSHTTPCookieMBS.NSHTTPCookieExpires)=d

// create cookie from properties
dim cookie as new NSHTTPCookieMBS(prop)
dim cookies(-1) as NSHTTPCookieMBS
cookies.Append cookie

// get request headers
dim dic as Dictionary = NSHTTPCookieMBS.requestHeaderFieldsWithCookies(cookies)

// and show them:
dim list(-1) as string

for each key as Variant in dic.keys
List.Append key.StringValue+": "+dic.Value(key).StringValue
next

MsgBox Join(list,EndOfLine)

cookies: The cookies from which the header fields are created.

Returns the dictionary of header fields created from the provided cookies. This dictionary can be used to add cookies to a request.

The items on this page are in the following plugins: MBS MacControls Plugin.


The biggest plugin in space...