Varnish Cache Plus



vmod_session is a small VMOD that lets manipulate session local variables. For now only the idle timout can be accessed.


Setting the session timout

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(...) {

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 timout 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();