<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSHTTPCookie/cookieWithProperties:",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSHTTPCookie(cm)cookieWithProperties:"
  },
  "title" : "cookieWithProperties:"
}
-->

# cookieWithProperties:

Creates and initializes an HTTP cookie object using the provided properties.

```
+ (NSHTTPCookie *) cookieWithProperties:(NSDictionary<NSString *,id> *) properties;
```

## Parameters

`properties`

The properties for the new cookie object, expressed as key value pairs.

## Return Value

The newly created cookie object. Returns `nil` if the provided properties are invalid.

## Discussion

To successfully create a cookie, you must provide values for (at least) the [`path`](/documentation/Foundation/HTTPCookiePropertyKey/path), [`name`](/documentation/Foundation/HTTPCookiePropertyKey/name), and [`value`](/documentation/Foundation/HTTPCookiePropertyKey/value) keys, and either the [`originURL`](/documentation/Foundation/HTTPCookiePropertyKey/originURL) key or the [`domain`](/documentation/Foundation/HTTPCookiePropertyKey/domain) key.

See Accepting cookies for more information on the available cookie attribute constants and the constraints imposed on the values in the dictionary.

---

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)