2.6 Understanding Session State Management

This section describes session statement management in Oracle Application Express.

2.6.1 What is Session State?

Hypertext Transfer Protocol (HTTP), the protocol over which HTML pages are most often delivered, is a stateless protocol. A web browser is only connected to the server for as long as it takes to download a complete page. In addition, each page request is treated by the server as an independent event, unrelated to any page requests that happened previously or that may occur in the future. To access form values entered on one page on a subsequent page, the values must be stored as session state. Oracle Application Express transparently maintains session state and provides developers with the ability to get and set session state values from any page in the application.

2.6.2 What Is a Session?

A session is a logical construct that establishes persistence (or stateful behavior) across page views. Each session is assigned a unique identifier. The Application Express engine uses this identifier (or session ID) to store and retrieve an application's working set of data (or session state) before and after each page view.

Because sessions are entirely independent of one another, any number of sessions can exist in the database at the same time. A user can also run multiple instances of an application simultaneously in different browser programs.

Sessions are logically and physically distinct from Oracle database sessions used to service page requests. A user runs an application in a single Oracle Application Express session from sign in to sign out with a typical duration measured in minutes or hours. Each page requested during that session results in the Application Express engine creating or reusing an Oracle database session to access database resources. Often these database sessions last just a fraction of a second.

See Also:

"Viewing Active Sessions" in Oracle Application Express Administration Guide

2.6.3 About Session IDs

The Application Express engine establishes the identity of the user for each page request and the session ID to fetch session state from the database. The most visible location of the session ID is in the URL for a page request. The session ID displays as the third parameter in the URL, for example:


In this example, the session ID is 220883407765693447.

Another visible location is in the page's HTML POST data and indirectly in the contents of a session cookie. This cookie is sent by the Application Express engine during authentication and is maintained for the life of the application (or browser) session.

Oracle Application Express assigns new session IDs during authentication processing, records the authenticated user's identity with the session ID, and continually checks the session ID in each page request's URL or POST data with the session cookie and the session record in the database. These checks provide users with flexibility and security.

While the session ID is the key to session state, the session cookie and the session record safeguard the integrity of the session ID and the authentication status of the user.

2.6.4 Viewing Session State

The behavior of an Oracle Application Express application is usually driven by values in session state. For example, a button may display conditionally based on the value of an item session state. This section describes how to view session state for a page. Viewing Session State for a Page

To view the session state for a page:

  1. Run the application as a developer.

  2. Locate the Developer toolbar at the bottom of the page.

    Description of toolbar.png follows
    Description of the illustration ''toolbar.png''

  3. Click Session on the Developer toolbar.

    The Session page appears. Using the Session Page

The Session page provides valuable information about the session in which the application is currently running.

To control the display of the Session Page:

  1. Page - Enter a page number.

  2. Find - Enter a string to search for.

  3. Rows - Select the number of rows to display.

  4. View - Select the information to display.

  5. Click Set.

    The following information displays at the top of the page:

    • Application - Identifies the application name.

    • Session - Displays the session ID for the current session.

    • User - Identifies the current user.

    • Workspace - Displays the current workspace ID.

    • Browser Language - Identifies the current browser language.

    Table 2-1 describes the information that displays on the Session page depending upon the View option you select.

    Table 2-1 View Options on the Session Page

    View Option Description

    View, Page Items

    Identify attributes of the page item, including the application ID, page number, item name, how the item displays (for example, check box, date picker, display only, text field, hidden, popup, radio group, and so on), the item value in session state, status of the session state (for example, Inserted, Updated, or Reset) and if the item is encrypted.

    See Also: "Understanding Page-Level Items"

    View, Application Items

    Application items are items that do not reside on a page. Application items are session state variables without the associated user interface properties.

    See Also: "Managing Application-Level Items" and "Understanding Substitution Strings" for information about referencing item values

    View, Session State

    Displays session state details, including the application ID, page number, item name, the item value in session state, how the item displays (for example, check box, date picker, display only, text field, hidden, popup, radio group, and so on), label, encryption status, and data item ID.

    View, Collections

    Displays currently defined collections.

    See Also: "About Using Collections"