Some examples of zf2 sessions usage:
Session creation:
use ZendSessionContainer;
$session = new Container('base');
Check that key exists in session:
$session->offsetExists('email')
Getting value from the session by key:
$email = $session->offsetGet('email');
Setting value in session:
$session->offsetSet('email', $email);
Unsetting value in session:
$session->offsetUnset('email');
And other easy way to use session are:
$session = new Container('foo');
// these are all equivalent means to the same end
$session['bar'] = 'foobar';
$session->bar = 'foobar';
$session->offsetSet('bar', 'foobar');
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…