| THE META-HTML LANGUAGE REFERENCE MANUAL

| [TOC] |

## Manual Page Viewer

Name: REQUIRE-SESSION

Section: Session Operators

Synopsis:

`<require-session [MISSING=MISSING-CODE] [TIMEOUT=TIMEOUT-CODE]>`

Description:

Check that the current session is valid and not timed out. If either of those things are true, the respective code is evaluated. Usually, the targets of TIMEOUT and MISSING are a `redirect` command which points to a page explaining the problem.

You could force an anonymous session with the following code:

      <set-var anonymous="Anonymous Session">
      <require-session
        missing="<create-session anonymous allow-multiple>
                 <redirect <get-var SID>/<get-var mhtml::current-doc>"
        timeout=<redirect /timed-out.mhtml>>

In the real world, additional care should be taken when returning new URLs. The variable MHTML::COOKIE-COMPATIBLE is `true` when the attached browser/server combination is capable of handling HTTP Cookies. In this case, it is preferable to use the HTTP Cookie handling facilities instead of returning the session ID in the URL. Here is how one might write the above example to handle both cases:

    <set-var anonymous="Anonymous Session" session-timeout=60>
    <require-session
     missing = <prog
                 <create-session anonymous allow-multiple>
                 <set-session-timeout <get-var session-timeout>>
                 <when <not <get-var mhtml::cookie-compatible>>>
                 <redirect <concat
                            <get-var mhtml::http-to-host>/
                            <get-var SID><get-var mhtml::relative-prefix>/
                            <get-var mhtml::current-doc>>>
                 </when>>
     timeout = <prog
                 <set-var SID="">
                 <if <get-var mhtml::cookie-compatible>
                     <replace-page
                      <get-var mhtml::relative-prefix>/timedout.mhtml>
                   <redirect
                    <get-var mhtml::url-to-dir-sans-sid>/timedout.mhtml>>>>

For more detail on the built-in variables provided by the Meta-HTML Server and CGI Engine, see Server Variables.

Edit Pointer
Function Index
Variable Index
Variable Editor

The META-HTML Reference Manual V1.4 Copyright © 1995, 1996, Brian J. Fox, 1996, 1997 Universal Access Inc.
Found a bug? Send mail to bug-manual@metahtml.com