title: PHP accessing array object
body: <p>I am using a third party software and the <code>print_r($_SESSION)</code> gives me this </p>
  
  <pre><code>[stsco-portal_current_user] =&gt; UserIdentity Object
      (
          [userName] =&gt; Gary
          [password] =&gt; 
          [persistent] =&gt; 
      )
  </code></pre>
  
  <p>I need to access the <code>userName</code> and have tried various combinations of the following </p>
  
  <pre><code>echo $_SESSION['stsco-portal_current_user']-&gt;$UserIdentity-&gt;['userName'];
  </code></pre>
  
  <p>keeps giving me an error. </p>
  
  <p>I know i can access it(used it before in another project using a differnt system) i just forgot how to do it. Any help ? </p>