---
title: "init(properties:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/httpcookie/init(properties:)"
---

# init(properties:)

Initializes an HTTP cookie object with the given cookie properties.

## Declaration

```swift
init?(properties: [HTTPCookiePropertyKey : Any])
```

## Parameters

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

## Return Value

Return Value A new cookie object, with the given properies.

## Discussion

Discussion This initializer returns nil if the provided properties are invalid. To successfully create a cookie, you must provide values for (at least) the path, name, and value keys, and either the originURL key or the domain key. See Accepting cookies for more information on the available cookie attribute constants and the constraints imposed on the values in the dictionary.

## See Also

### Creating cookies

- [cookies(withResponseHeaderFields:for:)](foundation/httpcookie/cookies(withresponseheaderfields:for:).md)
