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:
<CFSET session.variable_name
= value>
<% 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
:
<CFSET session.prodID = url.product>
<% 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:
<CFSET session.prodID = form.txtProduct>
<% Session("prodID") = Request.Form("txtProduct") %>