The session
vmod is a small VMOD that lets manipulate session local variables. For now only
the idle timeout can be accessed.
vcl 4.0;
import std;
import session;
sub vcl_recv {
session.set_timeout_idle(30s);
}
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);
}
}
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();
}
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();
}
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 DURATIONType: Function
Returns: None
Restricted to: client
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
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
The session
VMOD is available in Varnish Enterprise version 6.0.0r0
and later.