Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSHTTPCookieStorageMBS class.

NSHTTPCookieStorageMBS.Constructor   Private

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacControls Plugin 12.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The private constructor.

NSHTTPCookieStorageMBS.cookieAcceptPolicy as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The cookie storage's cookie accept policy.
Example
Select case NSHTTPCookieStorageMBS.sharedHTTPCookieStorage.cookieAcceptPolicy
case NSHTTPCookieStorageMBS.NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain
MsgBox "Cookies: only from main document domain"
case NSHTTPCookieStorageMBS.NSHTTPCookieAcceptPolicyNever
MsgBox "Cookies: never"
case NSHTTPCookieStorageMBS.NSHTTPCookieAcceptPolicyAlways
MsgBox "Cookies: always"
else
MsgBox "Cookies: unknown setting"
end Select

The default cookie accept policy is NSHTTPCookieAcceptPolicyAlways.

Changing the cookie policy affects all currently running applications using the cookie storage.
(Read and Write computed property)

NSHTTPCookieStorageMBS.cookies as NSHTTPCookieMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the cookie storage's cookies.
Example
// query list of all cookies in shared storage
dim cookies(-1) as NSHTTPCookieMBS = NSHTTPCookieStorageMBS.sharedHTTPCookieStorage.cookies

// we collect values
dim list(-1) as string
for each cookie as NSHTTPCookieMBS in cookies
List.Append cookie.name+": "+cookie.value
next

// and display them
MsgBox join(list, EndOfLine)

Returns an array containing all of the cookie storage's cookies.

NSHTTPCookieStorageMBS.cookiesForURL(URL as string) as NSHTTPCookieMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns all the cookie storage's cookies that are sent to a specified URL.
Example
// query list of all cookies in shared storage
dim cookies(-1) as NSHTTPCookieMBS = NSHTTPCookieStorageMBS.sharedHTTPCookieStorage.cookiesForURL("http://www.apple.com/")

// we collect values for apple.com:
dim list(-1) as string
for each cookie as NSHTTPCookieMBS in cookies
List.Append cookie.name+": "+cookie.value
next

// and display them
MsgBox join(list, EndOfLine)

An application can use NSHTTPCookie method requestHeaderFieldsWithCookies to turn this array into a set of header fields to add to an NSMutableURLRequest object.

NSHTTPCookieStorageMBS.cookiesToArray(cookies() as NSHTTPCookieMBS) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacControls Plugin 16.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Puts the cookie storage's cookies in the given array.
Example
// get storage
dim s as NSHTTPCookieStorageMBS = NSHTTPCookieStorageMBS.sharedHTTPCookieStorage

// predim an array with a lot of space
dim cookies(5000) as NSHTTPCookieMBS

// now ask plugin to put cookies inside
dim c as Integer = s.cookiesToArray(cookies)

// show count
MsgBox str(c)+" cookies"

// pick first and show name
dim cookie as NSHTTPCookieMBS = cookies(0)
MsgBox cookie.name

Returns total number of cookies.
This is for Xojo 2007 where the cookies function doesn't work.
For Xojo and Xojo you can use cookies function.

NSHTTPCookieStorageMBS.deleteCookie(cookie as NSHTTPCookieMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Deletes the specified cookie from the cookie storage.

NSHTTPCookieStorageMBS.removeCookiesSinceDate(d as date)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacControls Plugin 17.4 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Delete all cookies from the cookie storage since the provided date.

Available on macOS 10.10 or newer.

See also:

NSHTTPCookieStorageMBS.removeCookiesSinceDate(d as dateTime)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacControls Plugin 20.5 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Delete all cookies from the cookie storage since the provided date.

Available on macOS 10.10 or newer.

See also:

NSHTTPCookieStorageMBS.setCookie(cookie as NSHTTPCookieMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Stores a specified cookie in the cookie storage if the cookie accept policy permits.

The cookie replaces an existing cookie with the same name, domain, and path, if one exists in the cookie storage. This method accepts the cookie only if the receiver's cookie accept policy is NSHTTPCookieAcceptPolicyAlways or NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain. The cookie is ignored if the receiver's cookie accept policy is NSHTTPCookieAcceptPolicyNever.

NSHTTPCookieStorageMBS.setCookies(cookies() as NSHTTPCookieMBS, URL as string, mainDocumentURL as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa Networking MBS MacControls Plugin 11.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds an array of cookies to the receiver if the receiver's cookie acceptance policy permits.

cookies: The cookies to add.
URL: The URL associated with the added cookies.
mainDocumentURL: The URL of the main HTML document for the top-level frame, if known. Can be "". This URL is used to determine if the cookie should be accepted if the cookie accept policy is NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain.

The cookies will replace existing cookies with the same name, domain, and path, if one exists in the cookie storage. The cookie will be ignored if the receiver's cookie accept policy is NSHTTPCookieAcceptPolicyNever.

To store cookies from a set of response headers, an application can use cookiesWithResponseHeaderFields passing a header field dictionary and then use this method to store the resulting cookies in accordance with the receiver's cookie acceptance policy.

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


The biggest plugin in space...