I am trying to store a temporary data in the CSP.
I try to avoid ^Global and %session due to concurrency concerns, and avoid Javascript variable due to security concerns.
Then I encounter a confusion. Codes below are all in one single CSP:
<script language="Cache" runat="server">
s test = 1
</script>
<script language="Cache" method="Update">
s test = 2
</script>
<script language="Javascript">
function init(){
#server(..Update())#
alert("#(test)#");
}
</script>
<body onload="init();"></body>
During the page onload, the alert return test
as "1" rather than "2". What is happening here?
And is there any other better approach to store this kind of data in the CSP?
#()# is executed during page rendering.
so you are getting page like following. Right click on generated page and view its source code.
<script language="Javascript">
function init(){
#server(..Update())#
alert("1");
}
</script>
Also, consider that generally, different CSP requests are handled by different server processes, so it's not a good idea to handle state in global variables.
If you need to keep data for each user session, best way is to use %session