Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/Foundation.framework |
Availability | Available in Mac OS X v10.2 with Safari 1.0 installed. Available in Mac OS X v10.2.7 and later. |
Companion guide | |
Declared in | NSHTTPCookieStorage.h |
NSHTTPCookieStorage
implements a singleton object (shared instance) that manages the shared cookie storage. These cookies are shared among all applications and are kept in sync cross-process.
Note: Changes made to the cookie accept policy will affect all currently running applications using the cookie storage.
Returns the shared cookie storage instance.
+ (NSHTTPCookieStorage *)sharedHTTPCookieStorage
The shared cookie storage instance.
NSHTTPCookieStorage.h
Returns the receiver’s cookie accept policy.
- (NSHTTPCookieAcceptPolicy)cookieAcceptPolicy
The receiver's cookie accept policy. The default cookie accept policy is NSHTTPCookieAcceptPolicyAlways
.
NSHTTPCookieStorage.h
Returns the receiver’s cookies.
- (NSArray *)cookies
An array containing all of the receiver’s cookies.
NSHTTPCookieStorage.h
Returns all the receiver's cookies that will be sent to a specified URL.
- (NSArray *)cookiesForURL:(NSURL *)theURL
The URL to filter on.
An array of cookies whose URL matches the provided URL.
An application can use NSHTTPCookie
’s requestHeaderFieldsWithCookies:
method to turn this array into a set of header fields to add to an NSMutableURLRequest
object.
NSHTTPCookieStorage.h
Deletes the specified cookie from the receiver.
- (void)deleteCookie:(NSHTTPCookie *)aCookie
The cookie to delete.
NSHTTPCookieStorage.h
Stores a specified cookie in the receiver if the receiver's cookie accept policy permits.
- (void)setCookie:(NSHTTPCookie *)aCookie
The cookie to store.
The cookie will replace an existing cookie with the same name, domain and path, if one exists in the cookie storage. This method will accept the cookie only if the receiver’s cookie accept policy is NSHTTPCookieAcceptPolicyAlways
or NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain
. The cookie will be ignored if the receiver’s cookie accept policy is NSHTTPCookieAcceptPolicyNever
.
NSHTTPCookieStorage.h
Sets the cookie accept policy of the receiver
- (void)setCookieAcceptPolicy:(NSHTTPCookieAcceptPolicy)aPolicy
The new cookie accept policy.
The default cookie accept policy is NSHTTPCookieAcceptPolicyAlways
. Changing the cookie policy will affect all currently running applications using the cookie storage.
NSHTTPCookieStorage.h
Adds an array of cookies to the receiver if the receiver’s cookie acceptance policy permits.
- (void)setCookies:(NSArray *)cookies forURL:(NSURL *)theURL mainDocumentURL:(NSURL *)mainDocumentURL
The cookies to add.
The URL associated with the added cookies.
The URL of the main HTML document for the top-level frame, if known. Can be nil
. 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:forURL:
passing a header field dictionary and then use this method to store the resulting cookies in accordance with the receiver’s cookie acceptance policy.
NSHTTPCookieStorage.h
NSHTTPCookieAcceptPolicy
specifies the cookie acceptance policies implemented by the NSHTTPCookieStorage
class.
typedef enum { NSHTTPCookieAcceptPolicyAlways, NSHTTPCookieAcceptPolicyNever, NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain } NSHTTPCookieAcceptPolicy;
NSHTTPCookieAcceptPolicyAlways
Accept all cookies. This is the default cookie accept policy.
Available in Mac OS X v10.2 and later.
Declared in NSHTTPCookieStorage.h
.
NSHTTPCookieAcceptPolicyNever
Reject all cookies.
Available in Mac OS X v10.2 and later.
Declared in NSHTTPCookieStorage.h
.
NSHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain
Accept cookies only from the main document domain.
Available in Mac OS X v10.2 and later.
Declared in NSHTTPCookieStorage.h
.
NSHTTPCookieStorage.h
This notification is posted when the cookies stored in the NSHTTPCookieStorage
instance have changed. Since cookies are shared among applications, this notification can be sent in response to another application’s actions.
The notification object is the NSHTTPCookieStorage
instance. This notification does not contain a userInfo
dictionary.
NSHTTPCookieStorage.h
This notification is posted when the acceptance policy of the NSHTTPCookieStorage
instance has changed. Since cookies are shared among applications, this notification can be sent in response to another application’s actions.
The notification object is the NSHTTPCookieStorage
instance. This notification does not contain a userInfo
dictionary.
NSHTTPCookieStorage.h
© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)