为何在php命名空间内无法访问会话详细信息

I have developing a basic session handler class. The issue is when ever I am setting session into any controller action, same session details are not accessible in other action/controller. It displays me empty array. Entire system is php namespace oriented.

Reference: Session Manager

We do save and retrieve session as below.

use Cygnite\Common\SessionManager\Session;
use Cygnite\Common\Encrypt;                                    
$session = new Session(new Encrypt); 
$session->save($key, $value); 
$userDetails = $session->get($key); 

var_dump($userDetails); 

It works inside the same action and but when ever I am redirecting into some other controller ->action session doesn't display anything.

Can anyone help?

Probably you create in each controller new Session object. And it's quite possible you should create one Session object and inject it for example as constructor argument to other classes.

use Cygnite\Common\SessionManager\Session;
use Cygnite\Common\Encrypt;        

$session = new Session(new Encrypt);
$session->save('something', 'My data');

class A 
{
  private $session;

  public function __construct($session) {
      $this->session = $session;

      echo $this->sesssion->get('something'); // it should work

      $x = new Session(new Encrypt); 
      echo $x->get('something'); // possible it won't work
}