Skip to content

Instantly share code, notes, and snippets.

@harikt
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harikt/41028e9489396b066df2 to your computer and use it in GitHub Desktop.
Save harikt/41028e9489396b066df2 to your computer and use it in GitHub Desktop.
Zend Framework and Session and Remember Me
{
"require": {
"zendframework/zend-session": "~2.3",
"zendframework/zend-eventmanager": "~2.3"
}
}
<?php
require __DIR__ . '/vendor/autoload.php';
use Zend\Session\Config\StandardConfig;
use Zend\Session\SessionManager;
use Zend\Session\Container;
$config = new StandardConfig();
$config->setOptions(array(
'remember_me_seconds' => 3600,
'name' => 'namespace',
'cookie_lifetime' => 400,
'use_cookies' => true
));
$manager = new SessionManager($config);
$manager->start();
$container1 = new Container('namespace');
$container2 = new Container('namespace1');
if (isset($container1->item)) {
echo " <br /> " . $container1->item . ' container 1 ';
} else {
$container1->item = ' 1 from ';
$container1->getManager()->rememberMe(3600);
}
if (isset($container2->item)) {
echo " <br /> " . $container2->item . ' container 2';
} else {
$container2->item = '2 from ';
}
@harikt
Copy link
Author

harikt commented Oct 29, 2014

session.cookie_lifetime of php.ini is 0 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment