Last active
August 29, 2015 14:08
-
-
Save harikt/41028e9489396b066df2 to your computer and use it in GitHub Desktop.
Zend Framework and Session and Remember Me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"zendframework/zend-session": "~2.3", | |
"zendframework/zend-eventmanager": "~2.3" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 '; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
session.cookie_lifetime of php.ini is 0 .