Edit: I might have been unclear with my question. The authorization scheme is supposed to go off a page after the login page.
I am creating an Apex application with custom authentication, I successfully made the login page and am now able to set session item values. I made an apex application item called 'SESSION_USER_ROLE' and in my login authentication procedure I set the user role in the session state by using:
Apex_Util.Set_Session_State('SESSION_USER_ROLE', v_role);
After logging in with one of my user accounts and checking the session application items I can confirm that the item value and item name are properly set in the application items and session state.
However, when I try to access the value of the 'SESSION_USER_ROLE' item for an authorization scheme by using a PL/SQL function returning boolean I always seem to get 'false' even when I should be getting 'true'. This is the PL/SQL code I've been trying to use for authorization purpose:
DECLARE
v_role VARCHAR2(200);
v_auth boolean;
BEGIN
v_role := APEX_UTIL.FETCH_APP_ITEM('SESSION_USER_ROLE');
--This is the value of the SESSION_USER_ROLE for this specific user
if v_role = 'CEO' then
v_auth := true;
else
v_auth := false;
end if;
return v_auth;
END;
I don't understand what I'm doing wrong here. Is this not the correct way to retrieve the item value of SESSION_USER_ROLE?