title: Access another function Session
body: <p>I would like an access an array multiple Times For that purpose I store the array in Session array with following session declaration</p>
  
  <pre><code>$_SESSION['data'] = array();
  </code></pre>
  
  <blockquote>
    <p>Is there any Possible to use $_SESSION like common variable</p>
    
    <p>Intially it calls a function index(), and click anoher button it sets
    formval = 1 and goes to function index2</p>
  </blockquote>
  
  <p>　　</p>
  
  <pre><code>&lt;?php
  
  new SampleController();
  session_start();
  class SampleController {
      public function __construct() {
          if (isset($_REQUEST['formval']) &amp;&amp; $_REQUEST['formval'] == '1') {
              self::index2();
          } else {
              self::index();
          }
      }
  
      public function getfunc1() {
          $_SESSION['data'] = array();
          $datarray = array('0', '1', '2');
          $_SESSION['data'] = $datarray;
      }
  
      public function getfunc2() {
          print_r($_SESSION);
          $val = $_SESSION['data'];
      }
  }
  </code></pre>
  
  <p>It Shows Like </p>
  
  <blockquote>
    <p>Undefined variable: _SESSION</p>
  </blockquote>
  
  <p>I expect to need to access the <code>$_SESSION['data']</code> array</p>