Loading TOC...

MarkLogic 12 EA 2 Product Documentation
xdmp:set-session-field

xdmp:set-session-field(
   $name as xs:string,
   $value as item()*
) as item()*

Summary

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

Parameters
name The name of the session field.
value The value of the session field.

Required Privileges

http://marklogic.com/xdmp/privileges/xdmp-set-session-field

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.

Example

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.