How to clear a session container in Zend framework2

You almost had it, you just need to pass the namespace to the clear method


You can still treat the $_SESSION like an array, too, so the following also works


The Solution posted By @Crisp worked like a Charm But here is the alternative way what I found after a research to solve this problem

use Zend\Session\SessionManager;

$sessionManager = new SessionManager();

//get array of sessions from storage 
$array_of_sessions = $sessionManager->getStorage();

//Unset which ever container you want by passing its name ( ZF1 its called namespace ) 

I feel session manager is the one that we need to use to manage sessions whether to clear or read and container is one of the entity which is managed by session manager .

This may help others who are possessive in creating objects of each session container and call clear method .