DatsunBing
DatsunBing

Reputation: 9076

ZF2: Where are sessions stored?

My requirements of Zend\Session are pretty straightforward and my first access to it is with the following line of code:

$this->session = new Container('MySession');

My question is, where (by default) is this stored? In the case of ZF1, it was very simple: there was a file for each session under /data/session. The file name was a cookie id and you could 'cat' the file to see what was going on.

What's the buzz with ZF2? I've had a look through Zend\Session\Config files but I'm still in the dark.

Upvotes: 0

Views: 2052

Answers (3)

Diemuzi
Diemuzi

Reputation: 3527

When using just $this->session = new Container('MySession'); then your sessions will by default be saved wherever your php.ini is set to save them. Normal installations set them to be saved in the /tmp folder.

So you have two options:

1) Change the session.save_path in your php.ini to the new location.

2) You can do something like this:

$this->session = new SessionConfig();
$this->session->setOptions(array(
    'save_path' => __DIR__ . '/data/session'
));

Upvotes: 2

Skpd
Skpd

Reputation: 670

Session data location is not depends on framework. It is in php.ini, option session.save_path

Upvotes: 2

Carlos Robles
Carlos Robles

Reputation: 10947

Are you sure you didnt find anything under Zend\Session\Config\StandardConfig and Zend\Session\Config\SessionConfig ?

Also, take a look at Zend\Session\Storage

Then you can configure some stuff as you can read here:

http://framework.zend.com/manual/2.1/en/modules/zend.session.config.html

Upvotes: 0

Related Questions