;;; session.mhtml: -*- Meta-HTML -*-  DESCRIPTIVE TEXT.

;;;  Copyright (c) 1996 Brian J. Fox
;;;  Author: Brian J. Fox (bfox@ai.mit.edu) Wed May 29 08:10:02 1996.
<set-var mhtml::sid-prefix="/">
<set-var user-sid=<get-var SID>>
<require-session
 missing = <prog
             <set-var anonymous=anonymous>
             <create-session anonymous allow-multiple>
             <set-session-timeout 60>
             <set-session-var client="<get-var env::remote_host>">
             <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
             <package-delete temp>
             <set-var
               SID=<get-var user-SID>
               temp::sid=<get-var user-SID>
               temp::key="Anonymous Restarted"
               temp::start=<time>
               temp::access=<time>
               temp::timeout=60
               temp::data=""
               temp::length=<match <get-var temp::data> ".*" action=length>>
             <with-open-database db /tmp/sessions.db mode=write>
             <set-var saved-p =
               <database-save-package db <get-var temp::sid> temp strip=true>>
             </with-open-database>
             <set-session-var client="<get-var env::remote_host>">>>
