EWD Session Objects allow you to use the convenience and clarity of an object syntax for representing Session data, eg:


To create Session Objects within a back-end Caché script:

   d setSessionValue^%zewdAPI("person.name","Rob Tweed",sessid)
   d setSessionValue^%zewdAPI("person.address.country","UK",sessid)

To access and use Session Objects within a back-end Caché script:

   s name=$$getSessionValue^%zewdAPI("person.name",sessid)
   s country=$$getSessionValue^%zewdAPI("person.address.country",sessid)

EWD Session Objects map directly onto EWD Session arrays whose names are of the format prefix_name and they can freely interchanged, allowing some interesting tricks, eg:

   s myArr("city")="London"
   s myArr("details","country")="UK"
   d mergeArrayToSession^%zewdAPI(.myArr,"company_mgw",sessid)
   s city=$$getSessionValue^%zewdAPI("company.mgw.city",sessid)

EWD Session Objects are accessed within EWD pages using the normal convention for scalar values, but simply change the session name with the session object name , eg:

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