---
name: "libressl-SSL_CTX_flush_sessions"
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_CTX_flush_sessions"
---

# libressl-SSL\_CTX\_flush\_sessions(3)

remove expired sessions

## NAME

**SSL\_CTX\_flush\_sessions** – remove expired sessions

## SYNOPSIS

SSL Library (libssl, -lssl) libcrypto

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

*void*\

**SSL\_CTX\_flush\_sessions**(*SSL\_CTX \*ctx*, *long tm*);

## DESCRIPTION

**SSL\_CTX\_flush\_sessions**() causes a run through the session cache of *ctx* to remove sessions expired at time *tm*.

If enabled, the internal session cache will collect all sessions established up to the specified maximum number (see SSL\_CTX\_sess\_set\_cache\_size(3)). As sessions will not be reused once they are expired, they should be removed from the cache to save resources. This can either be done automatically whenever 255 new sessions were established (see SSL\_CTX\_set\_session\_cache\_mode(3)) or manually by calling **SSL\_CTX\_flush\_sessions**().

The parameter *tm* specifies the time which should be used for the expiration test, in most cases the actual time given by **time**(*0*) will be used.

**SSL\_CTX\_flush\_sessions**() will only check sessions stored in the internal cache. When a session is found and removed, the *remove\_session\_cb* is however called to synchronize with the external cache (see SSL\_CTX\_sess\_set\_get\_cb(3)).

## SEE ALSO

[ssl(3)](/ssl/3.md), SSL\_CTX\_sess\_set\_get\_cb(3), SSL\_CTX\_set\_session\_cache\_mode(3), SSL\_CTX\_set\_timeout(3)

## HISTORY

**SSL\_CTX\_flush\_sessions**() first appeared in SSLeay 0.8.0 and has been available since OpenBSD 2.4.
