Example of information stored in session variables, Asp and coldfusion application variables – Adobe Dreamweaver CC 2015 User Manual
Page 571

564
Dynamic sites, pages and web forms
Last updated 6/3/2015
ColdFusion
ASP
<% Session("prodID") = Request.Form("txtProduct") %>
Example of information stored in session variables
You’re working on a site with a large audience of senior citizens. In Dreamweaver, add two links to the Welcome screen
that let users customize the size of the site’s text. For larger, easy-to-read text, the user clicks one link, and for regular-
size text, the user clicks another link.
Each link has a URL parameter called fontsize that submits the user’s text preference to the server, as the following
Adobe ColdFusion® example shows:
Store the user’s text preference in a session variable and use it to set the font size on each page the user requests.
Near the top of the destination page, enter the following code to create a session called font_pref that stores the user’s
font size preference.
ColdFusion
ASP
<% Session("font_pref") = Request.QueryString("fontsize") %>
When the user clicks the hypertext link, the page sends the user’s text preference in a URL parameter to the destination
page. The code on the destination page stores the URL parameter in the font_pref session variable. For the duration of
the user’s session, all the pages of the application retrieve this value and display the selected font size.
ASP and ColdFusion application variables
In ASP and ColdFusion, you can use application variables to store and display information that is maintained for the
lifetime of the application and persists from user to user. The application’s lifetime lasts from the time the first user
requests a page in the application to the time the web server is stopped. (An application is defined as all the files in a
virtual directory and its subdirectories.)
Because application variables last for the lifetime of the application, and persist from user to user, they’re ideal for
storing information that must exist for all users, such as the current time and date. The value of the application variable
is defined in the application’s code.