Forum Discussion
Example passing information to a application from APM
- 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.
iRule:
when ACCESS_POLICY_COMPLETED { 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> <html> <body> <div id="result"></div> <script> 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..."; } </script> </body> </html>
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
You guys are legends, very keen to play around with your suggestions next week at work. This topic might even be a good one to write a full article with the various ways to do this
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com