Forum Discussion

Ravager's avatar
Icon for Altostratus rankAltostratus
Jul 08, 2021

Example passing information to a application from APM

I guess this is more of a request for a how would I question then anything and hopefully example articles or blogs exist already.   What I would like to understand is after authenticating someone...
  • Niels_van_Sluis's avatar
    Jul 10, 2021

    Hi Ravager,

    Your question inspired me to do some testing with passing APM session variables into sessionStorage. First I created an iRule to add the APM session variable into the sessionStorage of the webbrowser. And a simple webpage to query the browsers sessionStorage.


        set username [ACCESS::session data get session.logon.last.username]
        set html "<!DOCTYPE html>"
        append html "<body onload=\"location.reload()\"></body><script lang=\"javascript\">"
        append html "if (typeof(Storage) !== \"undefined\") \{"
        append html "sessionStorage.setItem(\"username\", \"$username\");"
        append html "\}</script></html>"
        ACCESS::respond 200 content $html

    HTML to put on the webserver:

    <!DOCTYPE html>
    <div id="result"></div>
    if (typeof(Storage) !== "undefined") {
      document.getElementById("result").innerHTML = "Username: " + sessionStorage.getItem("username");
    } else {
      document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";

    Here you can see the username is put into the browsers sessionStorage.

    Like always with the F5 BIG-IP, there is more than one way to do it. For example, you could also use HTTP Headers to pass information from APM to the web application. See:

    K74392192: How to insert APM Variables in backend headers to the application server