We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Getting all data stored in session

How can I get all variables stored in sesson?



5.2k
Accepted
answer

Hi,

There is a code which you can use:

for ($i=0; $i<5; $i++) {
    $this->session->set('var'.$i, $i);
}
foreach ($this->session->getIterator() as $key => $value) {
    var_dump($key);
    var_dump($value);
}


22.1k

Thanks, I hope to see session->get(null) method to get an array of all stored data in future realses.