<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: http-request-session.xml 18704 2013-07-15 20:21:22Z dizzzz $ --><book><bookinfo><productname>eXist-db – Open Source Native XML Database</productname><title>Request and session modules</title><orgname>The eXist-db Project</orgname><date>October 2012</date></bookinfo><chapter><title>HTTP-Related Functions in the request and session modules</title><section id="introduction"><title>Introduction</title><para>The request module (in the <uri>http://exist-db.org/xquery/request</uri> function
                namespace) contains functions for handling HTTP request parameters. The session
                module (in the <uri>http://exist-db.org/xquery/session</uri> function namespace)
                contains functions for handling HTTP session variables. Functions in these
                namespaces are only usable if the query is executed through the XQueryGenerator or
                the XQueryServlet (for more information consult eXist-db's <ulink url="devguide.xml">Developer's Guide</ulink> ).</para><variablelist><varlistentry><term>request:get-parameter(<emphasis>name</emphasis>, <emphasis>default
                            value</emphasis>)</term><listitem><para>This HTTP function expects two arguments: the first denotes the name
                            of the parameter, the second specifies a default value, which is
                            returned if the parameter is not set. This function returns a sequence
                            containing the values for the parameter. The above script
                            (Adding/Subtracting Two Numbers) offers an example of how
                                <command>request:get-parameter</command> can be used to read HTTP
                            request parameters.</para></listitem></varlistentry><varlistentry><term>request:get-uri()</term><listitem><para>This function returns the URI of the current request. To encode this
                            URI using the current session identifier, use the following
                            function:</para><synopsis>session:encode-url(request:get-uri())</synopsis></listitem></varlistentry><varlistentry><term>session:create()</term><listitem><para>This function creates a new HTTP session if none exists.</para><para>Other session functions read and set session attributes, among other
                            operations. For example, an XQuery or Java object value can be stored in
                            a session attribute, to cache query results. For more example scripts,
                            please look at our <ulink url="{demo}/examples/web/index.html">Examples</ulink> page,
                            under the XQuery Examples section.</para></listitem></varlistentry></variablelist></section></chapter></book>