Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

NSHTTPCookieStorageMBS.Constructor
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Networking MBS MacControls Plugin 12.3 Yes No No Yes, macOS only No
Function: The private constructor.

Feedback, Comments & Corrections

NSHTTPCookieStorageMBS.cookieAcceptPolicy as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
property Cocoa Networking MBS MacControls Plugin 11.1 Yes No No Yes, macOS only No
Function: 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
Notes:
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)

Feedback, Comments & Corrections

NSHTTPCookieStorageMBS.cookies as NSHTTPCookieMBS()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Networking MBS MacControls Plugin 11.1 Yes No No Yes, macOS only No
Function: 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)
Notes: Returns an array containing all of the cookie storage's cookies.

Feedback, Comments & Corrections

NSHTTPCookieStorageMBS.cookiesForURL(URL as string) as NSHTTPCookieMBS()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Networking MBS MacControls Plugin 11.1 Yes No No Yes, macOS only No
Function: 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)
Notes: An application can use NSHTTPCookie method requestHeaderFieldsWithCookies to turn this array into a set of header fields to add to an NSMutableURLRequest object.

Feedback, Comments & Corrections

NSHTTPCookieStorageMBS.cookiesToArray(cookies() as NSHTTPCookieMBS) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Networking MBS MacControls Plugin 16.1 Yes No No Yes, macOS only No
Function: 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
Notes:
Returns total number of cookies.
This is for REALbasic 2007 where the cookies function doesn't work.
For Real Studio and Xojo you can use cookies function.

Feedback, Comments & Corrections

NSHTTPCookieStorageMBS.deleteCookie(cookie as NSHTTPCookieMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Networking MBS MacControls Plugin 11.1 Yes No No Yes, macOS only No
Function: Deletes the specified cookie from the cookie storage.

Feedback, Comments & Corrections

NSHTTPCookieStorageMBS.removeCookiesSinceDate(d as date)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Networking MBS MacControls Plugin 17.4 Yes No No Yes, macOS only No
Function: Delete all cookies from the cookie storage since the provided date.
Notes: Available on macOS 10.10 or newer.

Feedback, Comments & Corrections

NSHTTPCookieStorageMBS.setCookie(cookie as NSHTTPCookieMBS)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Networking MBS MacControls Plugin 11.1 Yes No No Yes, macOS only No
Function: Stores a specified cookie in the cookie storage if the cookie accept policy permits.
Notes: 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.

Feedback, Comments & Corrections

NSHTTPCookieStorageMBS.setCookies(cookies() as NSHTTPCookieMBS, URL as string, mainDocumentURL as string)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method Cocoa Networking MBS MacControls Plugin 11.1 Yes No No Yes, macOS only No
Function: Adds an array of cookies to the receiver if the receiver's cookie acceptance policy permits.
Notes:
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.

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins