Accessing Data Stored In Session Variables - Adobe 38040334 - Dreamweaver CS3 User Manual

Pc
Hide thumbs Also See for 38040334 - Dreamweaver CS3:
Table of Contents

Advertisement

DREAMWEAVER CS3
535
User Guide
See also
"About URL and form parameters" on page 544
"Define form parameters" on page 557
"Adding dynamic content to pages" on page 564
"Accessing data stored in a database" on page 531

Accessing data stored in session variables

How session variables work
Session variables store information (usually form or URL parameters submitted by users) and make it available to all
of a web application's pages for the duration of the user's visit. For example, when users log on to a web portal that
provides access to e-mail, stock quotes, weather reports, and daily news, the web application stores the login infor-
mation in a session variable that identifies the user throughout the site's pages. This allows the user to see only the
types of content they have selected as they navigate through the site. Session variables can also provide a safety
mechanism by terminating the user's session if the account remains inactive for a certain period of time. This also
frees server memory and processing resources if the user forgets to log off a website.
Session variables store information for the life of the use session. The session begins when the user opens a page
within the application and ends when the user does not open another page in the application for a certain period of
time, or when the user explicitly terminates the session (typically by clicking a "log-off " link). While it exists, the
session is specific to an individual user, and every user has a separate session.
Use session variables to store information that every page in a web application can access. The information can be as
diverse as the user's name, preferred font size, or a flag indicating whether the user has successfully logged in.
Another common use of session variables is to keep a running tally, such as the number of questions answered
correctly so far in an online quiz, or the products the user selected so far from an online catalog.
Session variables can only function if the user's browser is configured to accept cookies. The server creates a session
ID number that uniquely identifies the user when the session is first initiated, then sends a cookie containing the ID
number to the user's browser. When the user requests another page on the server, the server reads the cookie in the
browser to identify the user and to retrieve the user's session variables stored in the server's memory.
Collecting, storing, and retrieving information in session variables
Before creating a session variable, you must first obtain the information you want to store, and then send it to the
server for storage. You can gather and send information to the server using HTML forms or hypertext links
containing URL parameters. You can also obtain information from cookies stored on the user's computer, from the
HTTP headers sent by the user's browser with a page request, or from a database.
A typical example of storing URL parameters in session variables is a product catalog that uses hard-coded URL
parameters created using a link to send product information back to the server to be stored in a session variable.
When a user clicks the "Add to shopping cart" link, the product ID is stored in a session variable while the user
continues to shop. When the user proceeds to the check-out page, the product ID stored in the session variable is
retrieved.
September 4, 2007

Advertisement

Table of Contents
loading

This manual is also suitable for:

Dreamweaver cs3

Table of Contents