Of course, the Oracle Learning Library team then asked me "Any ideas on how we can trap the 310 HTTP error code (too many redirects) and provide a user-friendly message (e.g. Enable cookies) on how to resolve the problem?" As it turns out, it's actually quite easy.
- The first step is ensuring that the page that is being accessed has the page attribute 'Authentication' set to 'Page is Public' instead of 'Page Requires Authentication' (thanks Christian). Even if you are using an application which has an authentication scheme of "No Authentication (using DAD)", the specific page attribute 'Authentication' must still be set to 'Page is Public'. This will stop APEX from doing a wild number of redirects if cookies are not enabled.
- Detecting if Cookies are Enabled in the Browser
- Our preferred approach (thanks Anthony) is to do this via a dynamic action on the public page with the following attributes:
- Advanced
- Name: Cookies not enabled
- Event: Page Load
- Condition: JavaScript expression
- Value: !navigator.cookieEnabled
- True Action: Alert
- Text: Cookies are not enabled!
- No False Action, leave blank.
- Alternatively, you could solve this via JavaScript in the page header, with something as simple as the following code in the page attribute "Execute when Page Loads":
if (!(navigator.cookieEnabled)) {alert('Cookies are not enabled');}
By doing this via a dynamic action, you get the benefit of not only having the alert message be translatable, but this is also much easier to find and maintain in your application instead of having JavaScript sprinkled around your application.
I have to point out that you will need Application Express 4.1.1 to achieve this. Application Express 4.1.1 was released on February 21, 2012. The Oracle Learning Library team has already updated their application to take advantage of this.
I have to point out that you will need Application Express 4.1.1 to achieve this. Application Express 4.1.1 was released on February 21, 2012. The Oracle Learning Library team has already updated their application to take advantage of this.