---
title: HTTPCookie
framework: foundation
role: symbol
role_heading: Class
path: foundation/httpcookie
---

# HTTPCookie

A representation of an HTTP cookie.

## Declaration

```swift
class HTTPCookie
```

## Overview

Overview An HTTPCookie object is immutable, initialized from a dictionary that contains the attributes of the cookie. This class supports two different cookie versions: Version 0: The original cookie format defined by Netscape. Most cookies are in this format. Version 1: The cookie format defined in RFC 6265, HTTP State Management Mechanism.

## Topics

### Creating cookies

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

### Converting cookies to request headers

- [requestHeaderFields(with:)](foundation/httpcookie/requestheaderfields(with:).md)

### Getting cookie host properties

- [domain](foundation/httpcookie/domain.md)
- [path](foundation/httpcookie/path.md)
- [portList](foundation/httpcookie/portlist.md)

### Getting cookie metadata

- [name](foundation/httpcookie/name.md)
- [value](foundation/httpcookie/value.md)
- [version](foundation/httpcookie/version.md)

### Determining cookie lifespan

- [expiresDate](foundation/httpcookie/expiresdate.md)
- [isSessionOnly](foundation/httpcookie/issessiononly.md)

### Securing cookies

- [isHTTPOnly](foundation/httpcookie/ishttponly.md)
- [isSecure](foundation/httpcookie/issecure.md)
- [sameSitePolicy](foundation/httpcookie/samesitepolicy.md)
- [HTTPCookieStringPolicy](foundation/httpcookiestringpolicy.md)

### Accessing cookie properties as key-value pairs

- [properties](foundation/httpcookie/properties.md)
- [HTTPCookiePropertyKey](foundation/httpcookiepropertykey.md)

### Getting user-readable cookie metadata

- [comment](foundation/httpcookie/comment.md)
- [commentURL](foundation/httpcookie/commenturl.md)

### Accepting cookies

- [HTTPCookie.AcceptPolicy](foundation/httpcookie/acceptpolicy.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Cookies

- [HTTPCookieStorage](foundation/httpcookiestorage.md)
