<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.setSessionField.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.setSessionField</api:function-name><api:suggest>xdmp.setsessionfield</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>setsessionfield</api:suggest><api:function-link mode="xquery" fullname="xdmp:set-session-field">/apidoc/8.0/xdmp:set-session-field.xml</api:function-link><api:function mode="javascript" name="setSessionField" type="builtin" lib="xdmp" category="AppServerBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.setSessionField"><api:summary>
  Sets the value of a named session field for the session created
  by the <code xmlns="http://www.w3.org/1999/xhtml">xdmp:login</code> function. 
</api:summary><api:params><api:param name="name" type="xs:string"><api:param-description>
    The name of the session field.</api:param-description><api:param-name>name</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="value" type="item()*"><api:param-description>
    The value of the session field. 
    <span class="javascript" xmlns="http://www.w3.org/1999/xhtml">If you pass in a single value, 
  it is treated as a ValueIterator 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 
  <a href="./xdmp.arrayValues">xdmp.arrayValues</a> on the array. </span>
    </api:param-description><api:param-name>value</api:param-name><api:param-type>ValueIterator</api:param-type></api:param></api:params><api:return>ValueIterator</api:return><api:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml"><code>http://marklogic.com/xdmp/privileges/xdmp-set-session-field</code></p>
</api:privilege><api:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">You can use the <code>xdmp:get-session-field-names</code> function
  to return the names of the fields in the session and the
  <code>xdmp:get-session-field</code> function
  to return a value set in a session field.</p>
  <p xmlns="http://www.w3.org/1999/xhtml">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 
  <code>fn:doc</code> 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.</p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.setSessionField("user", "marklogic");
=&gt; "marklogic"
</pre></api:example></api:function></api:function-page>