51.2 CREATE_SESSION Procedure

This procedure creates a new session for the given application, sets the environment, and runs the application's Initialization PL/SQL Code.

Syntax

APEX_SESSION.CREATE_SESSION (
   p_app_id                   IN NUMBER,
   p_page_id                  IN NUMBER,
   p_username                 IN VARCHAR2,
   p_call_post_authentication IN BOOLEAN DEFAULT FALSE );

Parameters

Parameters Description
p_app_id The application id.
p_page_id The application page.
p_username The session user.
p_call_post_authentication If true, call post-authentication procedure. The default is false.

Raises

WWV_FLOW.APP_NOT_FOUND_ERR: The application does not exist or the caller has no access to the workspace.

Example

Note:

The CREATE_SESSION procedure is not supported in the SQL Commands and SQL Scripts tools within SQL Workshop.

This example creates a session for EXAMPLE_USER in application 100 page 1, then prints the app id and session id.

begin
    apex_session.create_session (
    p_app_id   => 100,
    p_page_id  => 1,
    p_username => 'EXAMPLE_USER' );
    sys.dbms_output.put_line (
   'App is '||v('APP_ID')||', session is '||v('APP_SESSION'));
 end;