Oracle Apex - After Login Redirect the User to a Specific Page

This Oracle Apex tutorial will show you how you can redirect the user to a specific page conditionally after log-in.

Suppose you need to redirect the user to the Change Password page after their first login. You can use the following approach.

Oracle Apex - After Login Redirect the User to a Specific Page Example

In Oracle Apex, by default, the user is redirected to the homepage after login. So it is a good idea to create a Before Header Branch on the homepage and specify a server-side condition to check whether the password has been changed or not after the first login and if not changed, then redirect to the Change Password page.

You can have a field in your user master table or any config table as shown below:

alter table yourUserConfigTable 
    add password_changed varchar2(1) default 'N';

Now you have a field password_changed with default value 'N' meaning the password has not been changed after the first login. You can set it Y/N according to your need.

Now open your homepage (page no. 1) and click on the Pre-Rendering node to expand and under the Before Header node create a Branch. As shown in the below image:

Creating Branch to redirect the user in Oracle Apex.

Then set the following properties for the Branch:

  • Name: goto_ch_psw_page
  • Type: Page or URL (Redirect)
  • Target: Page No. to redirect (your change password page)
  • Server-side condition > Type: Rows Returned
  • Add the following SQL query to the SQL query field:
select 1 from YourUserConfigTable 
   where password_changed = 'N' 
   and username = :app_user

The above branch will only redirect the user if the password_changed flag is 'N'. After a successful change password, you should update the change_password flag to 'Y' in your change password page.

To learn how to create a Change Password page, check the following tutorial:

After updating the password_changed flag to 'Y', the user will be landed on the homepage on their next login.

Similarly, you can create multiple redirects based on multiple server-side conditions. In this case, the different users could be redirected to specific pages.

The above redirect logic will work with any authentication scheme.

Vinish Kapoor
Vinish Kapoor

Vinish Kapoor is a seasoned software development professional and a fervent enthusiast of artificial intelligence (AI). His impressive career spans over 20 years, marked by a relentless pursuit of innovation and excellence in the field of information technology. As an Oracle ACE, Vinish has distinguished himself as a leading expert in Oracle technologies, a title awarded to individuals who have demonstrated their deep commitment, leadership, and expertise in the Oracle community.

3 Comments

  1. How does one redirect a user to the originally requested page after log in. Suppose user had a fav link to page X which requires authentication. APEX forces the user to log in and then redirects to home page.

    • In this case, select the branch type as Function Returning URL (Redirect) and write a code in PL/SQL to return the URL.

    • I am experiencing more difficult situation where the user's fav link has page variables etc. All that is lost during the process of authentication. We need a mechanism by which Oracle will remember the "contents" of the original request and then redirect to that page with updated session information. It is more like a deep link to say a specific order/customer detail.

Comments are closed.