---
name: "libressl-SSL_SESSION_get_id"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-SSL_SESSION_get_id"
---

# libressl-SSL\_SESSION\_get\_id(3)

get and set the SSL session ID

## NAME

**SSL\_SESSION\_get\_id**, **SSL\_SESSION\_set1\_id** – get and set the SSL session ID

## SYNOPSIS

SSL Library (libssl, -lssl) libcrypto

**#include \<openssl/ssl.h\>**

*const* *unsigned* *char* *\**\

**SSL\_SESSION\_get\_id**(*const SSL\_SESSION \*s*, *unsigned int \*len*);

*int*\

**SSL\_SESSION\_set1\_id**(*SSL\_SESSION \*s*, *const unsigned char \*sid*, *unsigned int sid\_len*);

## DESCRIPTION

**SSL\_SESSION\_get\_id**() returns a pointer to the internal session ID value for the session *s*. The length of the ID in bytes is stored in \**len*. The length may be 0. The caller should not free the returned pointer directly.

**SSL\_SESSION\_set1\_id**() sets the session ID for *s* to a copy of the *sid* of length *sid\_len*.

## RETURN VALUES

**SSL\_SESSION\_get\_id**() returns a pointer to the session ID value.

**SSL\_SESSION\_set1\_id**() returns 1 for success and 0 for failure, for example if the supplied session ID length exceeds SSL\_MAX\_SSL\_SESSION\_ID\_LENGTH.

## SEE ALSO

[ssl(3)](/ssl/3.md), SSL\_copy\_session\_id(3), SSL\_get\_session(3), SSL\_SESSION\_get\_compress\_id(3), SSL\_SESSION\_get\_protocol\_version(3), SSL\_SESSION\_has\_ticket(3), SSL\_SESSION\_new(3)

## HISTORY

**SSL\_SESSION\_get\_id**() first appeared in OpenSSL 0.9.8 and has been available since OpenBSD 4.5.

**SSL\_SESSION\_set1\_id**() first appeared in OpenSSL 1.1.0 and has been available since OpenBSD 6.3.
