<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.13.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKHTTPCookieStore",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(cs)WKHTTPCookieStore"
  },
  "title" : "WKHTTPCookieStore"
}
-->

# WKHTTPCookieStore

An object that manages the HTTP cookies associated with a particular web view.

```
@MainActor class WKHTTPCookieStore
```

## Overview

Use a [`WKHTTPCookieStore`](/documentation/WebKit/WKHTTPCookieStore) to specify the initial cookies for your webpages, and to manage cookies for your web content. For example, you might use this object to delete the cookie for the current session when the user logs out. To detect when the webpage changes a cookie, install a cookie observer using the [`add(_:)`](/documentation/WebKit/WKHTTPCookieStore/add(_:)) method.

You don’t create a [`WKHTTPCookieStore`](/documentation/WebKit/WKHTTPCookieStore) object directly. Instead, retrieve this object from the [`WKWebsiteDataStore`](/documentation/WebKit/WKWebsiteDataStore) object in your web view’s configuration object.

## Topics

### Managing cookies

[`func getAllCookies(([HTTPCookie]) -> Void)`](/documentation/WebKit/WKHTTPCookieStore/getAllCookies(_:))

Fetches all stored cookies asynchronously and delivers them to the specified completion handler.

[`func setCookie(HTTPCookie, completionHandler: (() -> Void)?)`](/documentation/WebKit/WKHTTPCookieStore/setCookie(_:completionHandler:))

Adds a cookie to the cookie store.

[`func delete(HTTPCookie, completionHandler: (() -> Void)?)`](/documentation/WebKit/WKHTTPCookieStore/delete(_:completionHandler:))

Deletes the specified cookie.

### Permitting cookie storage

[`func getCookiePolicy((WKHTTPCookieStore.CookiePolicy) -> Void)`](/documentation/WebKit/WKHTTPCookieStore/getCookiePolicy(_:))

Returns a cookie policy that indicates whether the cookie store allows cookie storage.

[`func setCookiePolicy(WKHTTPCookieStore.CookiePolicy, completionHandler: (() -> Void)?)`](/documentation/WebKit/WKHTTPCookieStore/setCookiePolicy(_:completionHandler:))

Sets a cookie policy that indicates whether the cookie store allows cookie storage.

[`enum CookiePolicy`](/documentation/WebKit/WKHTTPCookieStore/CookiePolicy)

An enumeration with cases that indicate whether a cookie store allows cookie storage.

### Observing cookie store changes

[`func add(any WKHTTPCookieStoreObserver)`](/documentation/WebKit/WKHTTPCookieStore/add(_:))

Adds an observer to the cookie store.

[`func remove(any WKHTTPCookieStoreObserver)`](/documentation/WebKit/WKHTTPCookieStore/remove(_:))

Removes an observer from the cookie store.

[`protocol WKHTTPCookieStoreObserver`](/documentation/WebKit/WKHTTPCookieStoreObserver)

The methods to adopt in an object that monitors changes to a webpage’s cookies.

### Instance Methods

[`func getCookies(for: URL, completionHandler: ([HTTPCookie]) -> Void)`](/documentation/WebKit/WKHTTPCookieStore/getCookies(for:completionHandler:))

[`func setCookies([HTTPCookie], completionHandler: (() -> Void)?)`](/documentation/WebKit/WKHTTPCookieStore/setCookies(_:completionHandler:))

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`Sendable`](/documentation/Swift/Sendable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)