Storing information in session variables

Storing information in session variables

After information is sent to the server, you store the information in session variables by adding the appropriate code for your server model to the page specified by the URL or form parameter. Referred to as the destination page, this page is specified in either the action attribute of the HTML form or the href attribute of the hypertext link on the starting page.

The HTML syntax for each appears as follows:

<form action="destination.html" method="get" name="myform"> </form> 
<param name="href"value="destination.html">

Both the server technology used and the method you use to obtain the information determines the code used to store the information in a session variable. The basic syntax for each server technology is as follows:

ColdFusion

<CFSET session.variable_name = value>

ASP and ASP.NET

<% Session("variable_name") = value %>

The value expression is usually a server expression such as Request.Form("lastname"). For example, if you use a URL parameter called product (or an HTML form with the GET method and a text field called product) to gather information, the following statements store the information in a session variable called prodID:

ColdFusion

<CFSET session.prodID = url.product>

ASP and ASP.NET

<% Session("prodID") = Request.QueryString("product") %>

If you use an HTML form with the post method and a text field called txtProduct to gather the information, then the following statements store the information in the session variable:

ColdFusion

<CFSET session.prodID = form.txtProduct>

ASP and ASP.NET

<% Session("prodID") = Request.Form("txtProduct") %>

Related topics

  • Understanding session variables
  • Collecting information to store in session variables
  • Example of information stored in session variables
  • Retrieving data from session variables


Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Defining Sources of Dynamic Content
Developing Applications Rapidly