---
title: "setCookiePolicy(_:completionHandler:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkhttpcookiestore/setcookiepolicy(_:completionhandler:)"
---

# setCookiePolicy(_:completionHandler:)

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

## Declaration

```swift
func setCookiePolicy(_ policy: WKHTTPCookieStore.CookiePolicy, completionHandler: (@MainActor @Sendable () -> Void)? = nil)
```

```swift
func setCookiePolicy(_ policy: WKHTTPCookieStore.CookiePolicy) async
```

## Parameters

- `policy`: A cookie policy that indicates whether the cookie store allows cookie storage.
- `completionHandler`: A block the system invokes after it sets the cookie policy.

## See Also

### Permitting cookie storage

- [getCookiePolicy(_:)](webkit/wkhttpcookiestore/getcookiepolicy(_:).md)
- [WKHTTPCookieStore.CookiePolicy](webkit/wkhttpcookiestore/cookiepolicy.md)
