Tarantool CE/EE Documentation portal logo
Support
Updated at July 17, 2026   02:08 PM

box.session.on_connect()

box.session.on_connect([trigger-function [, old-trigger-function]])

Define a trigger for execution when a new session is created due to an event such as console.connect. The trigger function will be the first thing executed after a new session is created. If the trigger execution fails and raises an error, the error is sent to the client and the connection is closed.

Parameters:

  • trigger-function (function) — function which will become the trigger function

  • old-trigger-function (function) — existing trigger function which will be replaced by trigger-function

Returns

nil or function pointer

If the parameters are (nil, old-trigger-function), then the old trigger is deleted.

If both parameters are omitted, then the response is a list of existing trigger functions.

Details about trigger characteristics are in the triggers section.

Example:

tarantool> function f ()         >   x = x + 1         > endtarantool> box.session.on_connect(f)