Answers.Body: <pre><code>    Try following:
  
      // php code;
          $_SESSION['test'] = 'Hello World';
  
      // assign 'Hello World' to .tpl
          $this-&gt;assign('test', $_SESSION['test']);
  
      // use '{$test}' following in .tpl file to display on Thank you page, For e.g
         &lt;tr&gt;
           &lt;td&gt;{$test}&lt;/td&gt; // this will print 'Hello World' on page
         &lt;/tr&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-03T10:56:16.670Z
Answers.Text: Thanks Rohan but it's not working.
Answers.UserDisplayName: Negi
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-10-29T11:58:49.920Z
Answers.LastActivityDate: 2015-10-30T05:47:50.243Z
Answers.LastEditDate: 2015-10-30T05:47:50.243Z
Answers.UserDisplayName: 1990rk4
Body: <p>I am setting <code>$_SESSION</code> variable inside a payment response file and need this to display on Thank you page. Somehow nothing seems to work so far. </p>
  
  <p>Tried following things:</p>
  
  <pre><code>$_SESSION['test'] = 'Hello World'; // Inside payment response file
  </code></pre>
  
  <p>Need this in <code>confirm.tpl</code> file. Tried</p>
  
  <pre><code>{$session-&gt;get('test') // does not work
  {$smarty.session.test} // does not work
  </code></pre>
  
  <p>Tried so many other things but nothing seems to work. Also, it's not working for any other variable like <code>$_SERVER</code>, <code>$_POST</code> etc.</p>
  
  <p>Any ideas?</p>
  
Tags: <civicontribute><templates><smarty>
Title: How to get php $_SESSION variable inside a template
ThreadText: # How to get php $_SESSION variable inside a template
  
  (Asked by: username_0 on 2015-10-29)
  
  I am setting `$_SESSION` variable inside a payment response file and need this to display on Thank you page. Somehow nothing seems to work so far.
  
  Tried following things:
  
  ```
  $_SESSION['test'] = 'Hello World'; // Inside payment response file
  
  ```
  
  Need this in `confirm.tpl` file. Tried
  
  ```
  {$session->get('test') // does not work
  {$smarty.session.test} // does not work
  
  ```
  
  Tried so many other things but nothing seems to work. Also, it's not working for any other variable like `$_SERVER`, `$_POST` etc.
  
  Any ideas?
  
  **Tags:** civicontribute, templates, smarty
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-10-29. Score: 3
  
  ```
      Try following:
  
      // php code;
          $_SESSION['test'] = 'Hello World';
  
      // assign 'Hello World' to .tpl
          $this->assign('test', $_SESSION['test']);
  
      // use '{$test}' following in .tpl file to display on Thank you page, For e.g
         <tr>
           <td>{$test}</td> // this will print 'Hello World' on page
         </tr>
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks Rohan but it's not working.  
  
  ---
  
  