当前位置: 首页>>代码示例>>PHP>>正文


PHP SessionManager::setStorage方法代码示例

本文整理汇总了PHP中Zend\Session\SessionManager::setStorage方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionManager::setStorage方法的具体用法?PHP SessionManager::setStorage怎么用?PHP SessionManager::setStorage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Session\SessionManager的用法示例。


在下文中一共展示了SessionManager::setStorage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: configure

 public function configure($object, array $options = [])
 {
     $manager = new Session\SessionManager();
     $manager->setStorage(new Session\Storage\ArrayStorage());
     $manager->setSaveHandler(new Session\SaveHandler\Cache(new CacheStorageAdapterMemory()));
     $manager->setConfig(new Session\Config\StandardConfig());
     $session = new Session\Container('Default', $manager);
     $object->getServiceLocator()->set('Zend\\Session\\Container', $session);
 }
开发者ID:necromant2005,项目名称:tt-test,代码行数:9,代码来源:ZendSessionContainer.php

示例2: loginAction

 public function loginAction()
 {
     $request = $this->getRequest();
     $smarty = $this->getServiceLocator()->get('Smarty');
     if ($request->isGet()) {
         $smarty->assign('error', null);
         $smarty->display('admin/login.tpl');
     } else {
         $success = true;
         $error = null;
         $name = $request->getPost('name');
         $password = $request->getPost('password');
         $success = false;
         if (!$name || !$password) {
             $error = '用户名和密码不能为空';
         } else {
             $tableGateway = $this->getServiceLocator()->get('UserTable');
             $users = $tableGateway->findByName($name);
             if ($users->count() != 1) {
                 $error = '用户名或密码不正确';
             } else {
                 $password_additional = $this->getServiceLocator()->get('config')['password_additional'];
                 $realPassword = md5($password . $password_additional);
                 if ($users->current()->getPassword() === $realPassword) {
                     $session = new SessionManager();
                     $user = $users->current();
                     $storage = new ArrayStorage(['user' => $user]);
                     if ($session->setStorage($storage)) {
                         $success = true;
                     } else {
                         $error = '写入session失败';
                     }
                 } else {
                     $error = '密码不正确';
                 }
             }
         }
         if ($success) {
             $this->redirect()->toUrl('/admin');
         } else {
             $smarty->assign('error', $error);
             $smarty->display('admin/login.tpl');
         }
     }
 }
开发者ID:329379172,项目名称:tbtool,代码行数:45,代码来源:IndexController.php

示例3: StandardConfig

<?php

define('REDBEAN_MODEL_PREFIX', '../Model_');
require __DIR__ . '/../vendor/autoload.php';
require 'rb.php';
/*
require '../vendor/autoload.php';
$fvm = \RedBeanFVM\RedBeanFVM::getInstance();
gabordemooij\redbean\RedBeanPHP
*/
R::setup('mysql:host=localhost;dbname=smemailmf', 'root', '');
use Zend\Session\Config\StandardConfig;
use Zend\Session\SessionManager;
$config = new StandardConfig();
$config->setOptions(array('remember_me_seconds' => 1800000, 'name' => 'mailmf'));
$manager = new SessionManager($config);
//var_dump($manager);
use Zend\Session\Storage\ArrayStorage;
$populateStorage = array('foo' => 'bar');
$storage = new ArrayStorage($populateStorage);
$manager = new SessionManager();
$manager->setStorage($storage);
//var_dump($manager);
/*
$book = R::dispense("mail");
$book->author = "Santa Claus";
$book->title = "Secrets of Christmas";
$id = R::store( $book );
*/
开发者ID:klemensek,项目名称:SM_domailslikeamf,代码行数:29,代码来源:connect.php

示例4: getSessionAdapter

 /**
  * Retorna o adaptador de sessao
  * @param string $name
  * @return SessionContainer
  */
 public function getSessionAdapter($name = 'Default')
 {
     if (!isset($_SESSION[$name])) {
         $sessionConfig = new SessionConfig();
         $sessionConfig->setOptions($this->globalConfig['session']);
         $sessionStorage = new \Zend\Session\Storage\SessionArrayStorage();
         $sessionManager = new SessionManager();
         $sessionManager->rememberMe($this->globalConfig['session']['remember_me_seconds']);
         $sessionManager->forgetMe();
         $sessionManager->setConfig($sessionConfig);
         $sessionManager->setStorage($sessionStorage);
         $sessionNamespace = new SessionContainer($name, $sessionManager);
         $sessionNamespace->setExpirationSeconds(3600);
         if (!isset($sessionNamespace->init)) {
             $request = new \Zend\Http\PhpEnvironment\Request();
             $sessionNamespace->init = 1;
             $sessionNamespace->remoteAddr = $request->getServer('REMOTE_ADDR');
             $sessionNamespace->httpUserAgent = $request->getServer('HTTP_USER_AGENT');
             /*
              $chain = $sessionManager->getValidatorChain();
              $validatorUserAgent = new \Zend\Session\Validator\HttpUserAgent($sessionNamespace->httpUserAgent);
              $chain->attach('session.validate', array($validatorUserAgent, 'isValid'));
              $validatorAddr = new \Zend\Session\Validator\RemoteAddr($sessionNamespace->remoteAddr);
              $chain->attach('session.validate', array($validatorAddr, 'isValid'));
             
              $sessionManager->setValidatorChain($chain);
             * 
             */
         }
         $sessionNamespace->setDefaultManager($sessionManager);
     } else {
         $sessionNamespace = new SessionContainer($name);
         $sessionNamespace->setExpirationSeconds(3600);
     }
     $this->sessionAdapter = $sessionNamespace;
     return $sessionNamespace;
 }
开发者ID:fsvxavier,项目名称:cityware,代码行数:42,代码来源:AbstractActionController.php


注:本文中的Zend\Session\SessionManager::setStorage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。