119
Views
2
Comments
Is it possible to acess session variables values using JS?
Question

Title is pretty explanatory, need to access the session variables (defined in OS) using the JS defined in a web block, is it possible to do?


Thanks in advance!

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Fábio,

There is no direct way to achieve the mentioned objective but you can try the below steps:

Steps to Follow:

1) Within the WebBlock define an Input widget of which the variable property is mapped with Session Variable and also define the respective Input widget Style Classes with a pre-defined hidden CSS class as shown below..


2) Introduce an Expression widget with Escape Content property set to No

3) Add  the below JS code inside the expression widget

"<script>
    var ele = document.getElementById('" + HiddentInpt.Id + "');
    var sessionValue = ele.value;
    console.log(sessionValue);
</script>"


Hope this helps you!


Regards,

Benjith Sam

2025-12-30 10-21-36
Sughosh Deshpande

Hi Fábio,

I think you can try using "RunJavaScript" action under "HTTPRequestHandler". 

Regards,

Sughosh

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.