<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.login.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.login</api:function-name><api:suggest>xdmp.login</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>login</api:suggest><api:function-link mode="xquery" fullname="xdmp:login">/apidoc/8.0/xdmp:login.xml</api:function-link><api:function mode="javascript" name="login" type="builtin" lib="xdmp" category="AppServerBuiltins" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.login"><api:summary>
  <p xmlns="http://www.w3.org/1999/xhtml">Logs in a user on an application server that is using
  application-level authentication and sends a session cookie containing
  the session ID to the user's browser. 
  Returns true on success, false on failure.</p>
  <p xmlns="http://www.w3.org/1999/xhtml">
  If the user calling this function has the <code>xdmp:login</code>
  privilege, this function can be called without a password or with the empty
  sequence as the password.  In this case, login will succeed if
  the specified user exists.  Therefore, use the <code>xdmp:login</code>
  privilege carefully, as any user with that
  privilege will be able to execute code that uses the <code>xdmp:login</code>
  function to log in as any user.</p>
  <p xmlns="http://www.w3.org/1999/xhtml">Note that only HTTP App Servers allow application-level authentication,
  and therefore this function only works on an HTTP App Server; it always
  returns false against an XDBC server.
  </p>
</api:summary><api:params><api:param name="name" type="xs:string"><api:param-description>
    The username of the user to be logged in.
  </api:param-description><api:param-name>name</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="password" type="xs:string?" optional="true"><api:param-description>
    The user's password.  The password is not needed if the user
    calling the function has the xdmp:login execute privilege.
  </api:param-description><api:param-name>password</api:param-name><api:param-type>String?</api:param-type></api:param><api:param name="set-session" type="xs:boolean?" optional="true"><api:param-description>
    A boolean value specifying whether to set a session variable for the
    login.  The default is true.  Set to false to not set the
    session variable to maintain the user logged in.
  </api:param-description><api:param-name>set-session</api:param-name><api:param-type>Boolean?</api:param-type></api:param><api:param name="role-names" type="xs:string*" optional="true"><api:param-description>
    Roles that should be temporarily assigned to the user.
    The default is empty.
  </api:param-description><api:param-name>role-names</api:param-name><api:param-type>String[]</api:param-type></api:param></api:params><api:return>Boolean</api:return><api:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">
  The session exists in the E-node on which it was created; you cannot
  access that session from a different E-node.
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
  You can use the <code>xdmp:set-session-field</code> function to
  set a named value in the session and the <code>xdmp:get-session-field</code>
  function to return a value set in a session field. 
  The user session expires when the session reaches its timeout limit. 
  The session cookie remains on the browser until the browser exits or the
  cookie is explicitly removed by the user.
  </p>
</api:usage><!--JavaScript Examples --><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.login("mark","secret")
=&gt; true() -- if user "mark" has password "secret"
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.login("username") or xdmp.login("username", null)
=&gt; true() -- if user calling the function has the
               xdmp:login privilege
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.login("username") or xdmp.login("username", null)
=&gt; SEC-PRIV exception if the user calling the function does
              not have the xdmp:login privilege
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.login("username")
=&gt; true() -- if current user has the xdmp:login privilege
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.login("username")
=&gt; SEC-PRIV exception if current user does not have the
              xdmp:login privilege
</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.login("username", "secret", true,
		["hadoop-user-read","hadoop-user-write"]);
=&gt; true -- if current user has the xdmp:login privilege
</pre></api:example></api:function></api:function-page>