title: Keep Session Active script how to turn it on and off
body: <p>I got this script block from OpenNTF:</p>
  
  <pre><code>&lt;xp:div id="keepSessionAlive"&gt;&lt;/xp:div&gt;
  &lt;xp:scriptBlock id="scriptBlock1"&gt;
      &lt;xp:this.value&gt;
      &lt;![CDATA[   
          XSP.addOnLoad(function(){
              setInterval(function(){
                  XSP.partialRefreshPost("#{id:keepSessionAlive}", {});   
              }, 3000000)
          })]]&gt;
      &lt;/xp:this.value&gt;
  &lt;/xp:scriptBlock&gt;
  </code></pre>
  
  <p>I have added it to a control that displays a document. What I want to do is enable this script block from an edit button that toggles the document to EditMode, then turn it off when the document is saved. ie I only want the session to remain active if a document is being edited otherwise allow the Application Time Out settings to take place. 
  If I set a sessionScope variable to 0 or say 3000000 in the edit button and use that in place of the 3000000 in the code would that do it, but I think that would immediately time the session out. Or ???</p>