Loading TOC...


   $name as xs:string,
   $value as item()*
) as item()*


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.

Required Privileges


Usage Notes

You can use the xdmp:get-session-field-names function to return the names of the fields in the session and the xdmp:get-session-field 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:set-session-field("user", "marklogic")
=> "marklogic"

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


The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • In the current implementation this may block concurrent requests. See http://markmail.org/message/xr2dbdk4inj5e3yi for some discussion.
    • I think this behavior has changed in 7.0-5 and 8.0-1. It should no longer block.
  • It seems that set-server-field causes the app server to limit the browser to a single request at a time making asynchronous Ajax calls wait on the first one in. I could be wrong. Maybe someone can correct me?