Gathering information to store in session variables
Before you can use the value of a session variable in recordsets, you must gather the information, then store it in the session variable in the source code. Two common methods for gathering information are HTML forms and hypertext links containing URL parameters.
In the restaurant example discussed in the previous section, you decide to use an HTML form to let the user search for restaurants in a specific city.
On the application's start page, you create the form with a menu that sends the user's city to the server for storage in a session variable. The following is the simplified HTML code for the form:
<form name="fmPrefs" method="post" action="reviews.asp">
<p>Please choose your city:</p>
<select name="optCity">
<option value="LA">Los Angeles</option>
<option value="SF">San Francisco</option>
<option value="LV">Las Vegas</option>
<option value="SLC">Salt Lake City</option>
<option value="SEA">Seattle</option>
<option value="POR">Portland</option>
</select>
<input type="submit" name="Submit" value="Find Reviews">
</form>
If the user selects Los Angeles from the menu, the browser sends the form parameter, optCity=LA , to the server. The server places the parameter in an ASP variable called Request.Form("optCity"), then runs the ASP page, reviews.asp. The reviews.asp page contains code that copies the value of Request.Form("optCity") into a session variable, as described in the next section of this article.
|