Yesterday i needed to find out if the current page of an application is rendered using the public Session 0 (zero).
Seems to be a trivial task, simply look up :APP_SESSION and there you find ……a very big number. Even if the URL clearly shows that session 0 is used :APP_SESSION delivers the “real” internal session-id.
So how do you know if session zero is used?
At first i started to parse the actual URL and filter out the session-id. You can access the URL with OWA_UTIL.GET_CGI_ENV(‘QUERY_STRING’) . That works, but is too complicated when there is an easier possibility.
A look into the APEX_APPLICATION package reveals the global variable g_use_zero_sid which returns boolean indicating whether session zero is used, or not.
So if you want to know if the current page runs session zero, simply check APEX_APPLICATION.g_use_zero_sid .
Of course this is undocumented and might change in future releases, so use carefully and on your own risk.
But honestly, i don’t think this is going to change soon, since the packages modification history states this variable exist since 2006:
-- sspadafo 04/22/2006 - Added g_use_zero_sid for zero session ID feature