本文整理汇总了PHP中Zend\Session\SessionManager::writeClose方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::writeClose方法的具体用法?PHP SessionManager::writeClose怎么用?PHP SessionManager::writeClose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Session\SessionManager
的用法示例。
在下文中一共展示了SessionManager::writeClose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __invoke
public function __invoke(AuthenticationEvent $e)
{
$result = $e->getResult();
if ($result->isValid()) {
$this->sessionManager->writeClose();
}
}
示例2: disableWrite
/**
* Disable session writes after this point in time.
*
* @return void
*/
public function disableWrite()
{
// Set the flag
$this->disableWrite = true;
// If the session manager is already instantiated, close it!
if (null !== $this->manager) {
$this->manager->writeClose();
}
}
示例3: authListener
/**
* @param AuthenticationEvent $e
*/
public function authListener(AuthenticationEvent $e)
{
$result = $e->getResult();
if ($result->isValid()) {
if ($this->rememberMe) {
$this->sessionManager->rememberMe();
} else {
$this->sessionManager->forgetMe();
}
$this->sessionManager->writeClose();
}
}
示例4: userAuthentication
protected function userAuthentication($data)
{
$auth = $this->authService;
$adapter = $auth->getAdapter();
$adapter->setIdentityValue($data['username']);
$adapter->setCredentialValue($data['password']);
$authResult = $auth->authenticate();
if ($authResult->isValid()) {
$identity = $authResult->getIdentity();
$auth->getStorage()->write($identity);
$sessionManager = new SessionManager();
if ($data['rememberme']) {
$sessionManager->rememberMe();
}
// store user roles in a session container
$userContainer = new Container('User');
$userContainer->offsetSet('id', $identity->getUserId());
$userRoles = $identity->getRole()->toArray();
$roleNames = array();
foreach ($userRoles as $userRole) {
$roleNames[] = $userRole->getRoleName();
}
$userContainer->offsetSet('activeRole', $roleNames[0]);
$userContainer->offsetSet('allRoles', $roleNames);
$sessionManager->writeClose();
return true;
}
return false;
}
示例5: writeClose
/**
* Write session to save handler and close
*
* Once done, the Storage object will be marked as isImmutable.
*
* @return void
*/
public function writeClose()
{
// Skip storage writing if validation is failed
if (!$this->isValid()) {
//$this->destroy();
return;
}
// Set metadata for validators
$storage = $this->getStorage();
if (!$storage->isImmutable() && $this->validators) {
$storage->setMetaData('_VALID', $this->validators);
}
parent::writeClose();
}
示例6: registerShutdownFunction
/**
* According to the PHP manual, session_write_close should always be
* registered as a shutdown function when using an object as a session
* handler: http://us.php.net/manual/en/function.session-set-save-handler.php
*
* This method sets that up.
*
* @param SessionManager $sessionManager Session manager instance
*
* @return void
*/
protected function registerShutdownFunction(SessionManager $sessionManager)
{
register_shutdown_function(function () use($sessionManager) {
// If storage is immutable, the session is already closed:
if (!$sessionManager->getStorage()->isImmutable()) {
$sessionManager->writeClose();
}
});
}