Skip to content

adm_session_api

Ends the APEX sessions of a user.

The role and the active flag of a user are read once, when a person signs in (the application item AI_USER_ROLE is an after-login computation). A session that is open keeps what it read. So when a role changes or an account is deactivated, the product ends every APEX session of that user: the next request of the person shows the login page, and the new login follows the new role. adm_user_api.change_user_role, adm_user_api.deactivate_user and adm_user_api.migrate_user call this package; you only need it if you change adm_users with your own SQL.

Which sessions are meant: every session of the user name in the workspaces of the schema. The APEX views do not tell which application a session belongs to, so a session of the same user in another application of the same workspace ends as well.

Ends the APEX sessions of one user, except the session that makes the call.

The sessions are found in apex_workspace_sessions by the user name (any case) and removed with apex_session.delete_session. The call works inside an APEX request and in plain SQL, where it sets the workspace of the schema first. A session that has expired already is left alone.

The session of the caller stays, because ending the session that runs the request would run the cleanup code of the application and break the request. When an administrator changes their own role, their own session therefore keeps the old role until it ends.

The call never raises and never stops the change that called it. When APEX or a privilege is missing, or one session cannot be deleted, it logs the problem and goes on.

The call does not commit or roll back the transaction of the caller. APEX commits when it deletes a session, so the work runs in an autonomous transaction.

Signature:

function end_user_sessions (
p_username in varchar2
) return pls_integer;

Parameters:

Name Direction Type Description
p_username in varchar2 The user name, in any case

Returns: pls_integer - The number of sessions that were ended