To create a simple scalar session value within a back-end Caché script:

   d setSessionValue^%zewdAPI(sessionName,sessionValue,sessid)

   where:

     sessionName  = the name of the session variable you want to create
     sessionValue = the value of the session variable
     sessid       = the EWD Session Id, passed automatically into your script

   eg:

   d setSessionValue^%zewdAPI("world","hello world!",sessid)

To access a simple scalar session value within a back-end Caché script:

   s value=$$getSessionValue^%zewdAPI(sessionName,sessid)

   where:

     sessionName  = the name of the session variable you want to create
     sessid       = the EWD Session Id, passed automatically into your script

   eg:

   s helloWorld=$$getSessionValue^%zewdAPI("world",sessid)

To access a simple scalar session value within an EWD page use the syntax <?= #sessionName ?>. You can refer to EWD Session variables pretty much anywhere inside your EWD page, including Javascript, eg:

  <ewd:config isFirstPage="false" prePageScript="##class(ewd.test).getMyData">
  <html>
   <head>
    <title>EWD Page using Session Variables</title>
    <script language="javascript">
      function showIt() {
        var myVar = '<?= #mySessVar1 ?>' ;
        alert(myVar) ;
      }
    </script>
   </head>
   <body>
     <h3>This page accesses EWD Session Variables</h3>
     <div>Example value = <?= #myExample ?></div>
     <div>
       <input type="button name="x1" value="Show Value" onClick="showIt()" />
     </div>
   </body>
  </html>