;;; sec7.mhtml: -*- Meta-HTML -*- 

;;;  Copyright (c) 1996 Universal Access Inc.
;;;  Author: Henry Minsky (hqm@ua.com) Sun Sep 15 11:06:38 1996.
<set-var title="Using Sessions">
<include header.mhtml>

<plain-text>
  <pagelist-control-panel>
  <h2>Using Sessions</h2>

  In many cases, when you write a Web application, you want
  to save and refer to data which is persistent across 
  multiple page retrievals, and across some duration of time.

  You also may want to require users to identify themselves with
  a login name and password, and then  associate certain state with 
  their actions. 

  In <meta-html>, there is a built-in feature called a <i>session</i>
  which allows you to create what is effectively a persistent data
  object which provides all the features of a continuous connection
  between a browser and the Web server, on a per-user basis.

  <h2> Example: Remembering A User's Name</h2>

  Let's say you want to have a personalized Web site, where you refer to
  each user by their own name on every page. We can use sessions to let
  a user enter their name if necessary, and then access that
  information from any web page, at any time. 

  Please fill out the sample form below, right now, and press
  the "Enter Data" button:
</plain-text>

<example-table result>

<form action=<thisdoc> method=post>
  Enter your first name: <input type=text name=firstname><br>
  Enter your last name: <input type=text name=lastname><br>
  Favorite color: <input type=text name=color><br>
  <input type=submit value="Enter Data">
</form>

<when <get-var posted::firstname>>
  <set-session-var
    firstname=<get-var posted::firstname>
    lastname=<get-var posted::lastname>
    favorite-color=<get-var posted::color>>
</when>

<font size=+1>
<when <get-session-var firstname>>
  Hello, <get-session-var firstname>. 
</when>

<when <get-session-var favorite-color>>
  I hear your favorite color is <font color=<get-session-var favorite-color>>
  <get-session-var favorite-color></font>.
</when>
</font>
</example-table>

<pagelist-control-panel>
<include footer.mhtml>
