Khushboo
Khushboo

Reputation: 475

How to check and get session value on view file in zend framework 2

I am working in zend framework 2.I want to know in view file and layout file [.phtml] how can I access session data.

I am accessing session in controller like below:

$session = new \Zend\Session\Container('identity');

But I want to access this session on view file. can anyone help me?

Upvotes: 1

Views: 853

Answers (1)

Wilt
Wilt

Reputation: 44422

You can simply pass data to your view inside your controller.
Check the documentation for examples:

$view = new ViewModel(array(
    'identity' => $identity,
));

Upvotes: 1

Related Questions