Changing the Login and Start Pages

Sometimes the simplest things make the biggest difference. Some users want to see a summary screen when they access an application, others want to get straight to business. If we can reduce the number of clicks required to get users to their desired page then we have happy customers. So how can you tailor your APEX application so that users aren’t just taken to Page 1 when they log in? And what if you don’t want to have page 101 as your login page?

Changing the Start Page

If you take a look at the login page that’s been created for your application you’ll see there is a process on the page called login. The source for this process should be something like:

wwv_flow_custom_auth_std.login(
P_UNAME => :P2_USERNAME,
P_PASSWORD => :P2_PASSWORD,
P_SESSION_ID => v('APP_SESSION'),
P_FLOW_PAGE => :APP_ID||':1'
);

P_FLOW_PAGE determines the page the user is redirected to after logging in. You could easily change this to be hard-coded to a different page, a dynamically determined page or a page stored for each user in a table.

For example:

DECLARE
v_start_page number(10);
BEGIN
BEGIN
SELECT start_page
INTO v_start_page
FROM apex_users
WHERE upper(name) = upper(:P2_USERNAME);
EXCEPTION
WHEN no_data_found THEN
v_start_page := 1;
END;
wwv_flow_custom_auth_std.login(
P_UNAME => :P2_USERNAME,
P_PASSWORD => :P2_PASSWORD,
P_SESSION_ID => v('APP_SESSION'),
P_FLOW_PAGE => :APP_ID||':'||nvl(v_start_page,1)
);
END;

Changing the Login Page

To keep all of the pages relating to certain areas together, we’ve changed the page that users use to login. We wanted all of the generic pages that every user needed to access to be numbered below 100. A login page of 101 didn’t fit with this, so we copied login page 101 (it seemed the easiest option) and created a new page 2. In Shared Components > Authentication Schemes we selected Database Account, which is the option we are using. On this page, in the Page Session Management section, there is a Session Not Valid Page. We changed this value from 101 to 2. Now, when the session is not valid, APEX redirects to page 2 – our new login page. This allowed us to delete page 101, customise page 2 for our requirements and keep everything tidy.

Sara

Sara Blair is a freelance Oracle developer with over 10 years Oracle experience. She has been working with Oracle APEX for nearly 4 years since htmldb 1.5, and is available to hire through Silvercore Solutions.

7 Responses to “Changing the Login and Start Pages”

  • Dan Nguyen says:

    I tried both of your code by hard code or a SQL. Not work.

    After changed the code, it work only the first logon, but log on after the first time, it always starts with the page specified in the URL

    http://meps.ci.stpaul.mn.us:7777/pls/amanda/f?p=408:1

    • Sara Blair says:

      Hi Dan

      My understanding is that if you specify a page in the URL then it will go to that page. The login page only comes into effect if you don’t specify the page and you’re going to within the application. One use of this is that you have an application that automatically emails you when an event happens, the URL to the application contained in the email could take you directly to a page with more information on the event. You wouldn’t want to be taken to your normal home page within the application to then have to navigate through your application to find details of the event.

      If you go to the URL you’ve specified without the :1 at the end then it should take you to the correct page.

      Hope this helps.

      Regards
      Sara

  • Ranga says:

    This is partially correct. To change the login page read the
    http://dgielis.blogspot.com/2007/05/change-default-first-page-in-apex.html

    we need to change the login page details at 3 places,
    1. Application Builder > Your Application > Page 101 > Processes (Page Processing) > Login
    2. Shared Components > Security > Authentication Schemes > Your Authentication
    3. Shared Components > Security > Edit Security Attributes

    • Sara Blair says:

      Hi Ranga

      Dimitri’s blog post is doing something different and isn’t just changing the login page. If you want to just change the login page then you only need to do the step detailed above.

      Regards
      Sara

  • Lala says:

    Hi Sara,
    how do i specify different login pages for different users? For example, i want users with role_id=1 to be directed to page 1 after loggin in and users with role_id = 2 to be directed to page 2..
    thanks

    • Sara Blair says:

      Hi Lala

      This can be done by changing the Start Page as shown in the example above. You would just need to change the SELECT statement that populates the v_start_page variable to meet your requirements.

      Hope this helps.

      Sara

  • Drew says:

    Worked perfectly for my needs using role-based logic, thanks!

Comments can no longer be submitted.