<!--
{
  "availability" : [
    "iOS: 5.0.0 - 13.0.0",
    "iPadOS: 5.0.0 - 13.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.8.0 - 10.15.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SSLSetDatagramHelloCookie(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SSLSetDatagramHelloCookie"
  },
  "title" : "SSLSetDatagramHelloCookie(_:_:_:)"
}
-->

# SSLSetDatagramHelloCookie(_:_:_:)

Sets the cookie value used in the Datagram Transport Layer Security (DTLS) hello message.

```
func SSLSetDatagramHelloCookie(_ dtlsContext: SSLContext, _ cookie: UnsafeRawPointer?, _ cookieLen: Int) -> OSStatus
```

## Parameters

`dtlsContext`

The SSL context associated with the connection.

`cookie`

The cookie value.

`cookieLen`

The length of the cookie (up to 32 bytes).

## Return Value

A result code. See [Secure Transport Result Codes](/documentation/Security/secure-transport-result-codes).

## Discussion

This function should be called only on the server side, and is optional. The default cookie is a zero-length cookie.

---

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)