Loading TOC...


   name as String,
   value as Sequence
) as Sequence


Sets the value of a named session field for the session created by the xdmp.login function.

name The name of the session field.
value The value of the session field. If you pass in a single value, it is treated as a Sequence with that single item; therefore, if you pass in an array, the array is treated as a single value (not as one value for each item in the array). If you mean to pass in the values of each item in the array, then you can call xdmp.arrayValues on the array.

Required Privileges


Usage Notes

You can use the xdmp.getSessionFieldNames function to return the names of the fields in the session and the xdmp.getSessionField function to return a value set in a session field.

If you set a session or server field to a value that comes from a database node (for example, from the value of a search or the fn.doc function), then that session or server field expires after the request time limit (10 minutes by default). These fields expire because they contain references to stands in the database, and as long as those references exist the stand cannot be reclaimed (merged). To keep such a node in a session or server field, make a copy of the node before adding it to the session or server field instead of using the node directly from the database.


xdmp.setSessionField("user", "marklogic");
=> "marklogic"

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.