Database Reference
In-Depth Information
The session Extension Module
A session represents the interaction with a server for a specific client over a period of
time. You may store data in the session that is available across requests for the same
client. Each client
may
have a distinct session with the server. A session is accessed
with the
session
extension module. This module is really just a very simple XQuery
Some usage hints:
• A session must be created with the
session:create
function. Lots of other func‐
tions that do something with a session create it implicitly for you, but it can
never hurt to create it explicitly with
session:create
. If the session already
exists, the call is ignored.
• A session can hold attributes that are name/value pairs. Attribute values can be
anything from simple strings to complex XML fragments. Use the functions
session:set-attribute
and
session:get-attribute
to work with these.
• Sessions invalidate automatically after not being accessed for a certain amount of
time. You can control this interval using the
session:get-max-inactive-
interval
and
session:set-max-inactive-interval
functions.
The response Extension Module
You control the response to a request via the
response
extension module. This mod‐
ule is really just a very simple XQuery wrapper around the underlying
HttpServletResponse
Java class
that eXist handles for you. Useful functionality here
includes:
• Setting cookies with the
response:set-cookie
function
• Explicitly setting response headers and the overall status code with the
response:set-header
and
response:set-status-code
functions
• Redirecting the client to another page with
response:redirect-to
• Streaming data directly to the output with the
response:stream
and
response:stream-binary
functions (useful for creating download functionality,
as described next)
Creating “download XML file” functionality
Creating a download function for an XML file, in which the browser asks you where
to store it instead of displaying it, is not as easy as it may sound. You have to trick the
Search WWH ::
Custom Search