phpzend-framework2zend-session

Zend Framework 2 Session


Full example of how to use Zend Framework 2 Session in Controllers, and display the session variable to the view (.phtml).


Solution

  • I guess the links below would be a good starting point.

    Links:

    Using Sessions in Zend Framework 2

    Using Sessions In Zend Framework 2 – Part 1

    Session Container

    update: in your view action inside a controller add them in the ViewModel.

            //session 
            $session = new Container('somecontainer');
            $poster = $session->somename;//$session->somename holds data set from another action
    
            $view = new ViewModel(array(
                'poster' => $poster,
    
            ));
            return $view;
    

    and inside the view depending on the type of the variable you use it

    echo $poster;//will echo the session message.