Search
Varnish Enterprise

Introduction Installation Upgrading Troubleshooting Changelog Changelog for 6.0.x Changes (Varnish Cache 4.1) Changes (Varnish Cache Plus 4.1) Known Issues Features Backend SSL/TLS Client SSL/TLS termination Cluster In-Process TLS MSE 4 Basic Configuration / Getting Started Configuration Persisted caching Categories Configuration Reference MSE 3.0 Settings mkfs.mse Memory Governor MSE 2.0 NUMA Parallel ESI Backend health counter HTTP/2 Support JSON Logging TCP Only Probes Timeouts Transit Buffer Varnish scoreboard VMODs Accept Accounting ACL (aclplus) ActiveDNS Akamai Connector AWS VCL Body Access & Transformation (xbody) Brotli Cookie Plus (cookieplus) DeviceAtlas DeviceAtlas3 Digest Dynamic backends (goto) Edgestash File Format Geolocation (geoip/mmdb) Header Manipulation (headerplus) HTTP communication (http) Image JSON parsing (json) JWT Key value storage (kvstore) Least connections director (leastconn) Module to control the built-in HTTP2 transport (h2) MSE control (mse) MSE4 control (mse4) Probe Proxy ProxyV2 TLV Attribute Extraction (proxy) Pseudo Random Number Generator Purge (purge/softpurge) Real-time Status (rtstatus) Reverse DNS (resolver) Rewrite S3 VMOD Session Slicer SQLite3 Stale Standard (std) Stat (Prometheus) Strings (str) Synthetic backends (synthbackend) Tag-based invalidation (Ykey/Xkey) TCP configuration (tcp) TLS Total Encryption (crypto) Unified director object (udo) Uniform Resource Identifier (uri) Unix Socket Utilities (unix) URL Plus (urlplus) Utils Vsthrottle

Session

Description

The session vmod is a small VMOD that lets manipulate session local variables. For now only the idle timeout can be accessed.

Examples

Basic Usage

vcl 4.0;
import std;
import session;

sub vcl_recv {
  session.set_timeout_idle(30s);
}

Setting the session timeout

To set the connection timeout, use session.set_timeout_idle(). The timeout will be set for the current session only, and will silently fail if the session is not available in the current VCL sub.

sub vcl_recv {
  if(...) {
    session.set_timeout_idle(300s);
  }
}

Reading the session timeout

To get the connection timeout use session.get_timeout_idle(). If no session is available in the VCL sub, or if the timeout for this session has not been set in VCL, the default timeout will be returned.

sub vcl_deliver {
  set resp.http.x-timeout-idle = session.get_timeout_idle();
}

Checking if the session timeout is set

If you want to know if the session timeout is set, use session.is_timeout_set().

This function returns true if the idle timeout has been set for the session. The return value is always false if called from a VCL sub where the session is not available.

sub vcl_deliver {
  set resp.http.x-is-session-timeout-set = session.is_timeout_set();
}

API

set_timeout_idle

VOID set_timeout_idle(DURATION timeout)

Set the session idle timeout. The timeout will be set for the current session only, and will silently fail if the session is not available in the current VCL sub.

Arguments:

  • timeout accepts type DURATION

Type: Function

Returns: None

Restricted to: client

get_timeout_idle

DURATION get_timeout_idle()

Get the session idle timeout. If no session is available in the VCL sub, or if the timeout for this session has not been set in VCL, the default timeout will be returned.

Arguments: None

Type: Function

Returns: Duration

Restricted to: client

is_timeout_set

BOOL is_timeout_set()

This function returns true if the idle timeout has been set for this session. Always false if called from a VCL sub where the session is not available.

Arguments: None

Type: Function

Returns: Bool

Restricted to: client

Availability

The session VMOD is available in Varnish Enterprise version 6.0.0r0 and later.


®Varnish Software, Wallingatan 12, 111 60 Stockholm, Organization nr. 556805-6203