Search
Varnish Enterprise

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