Chinaunix首页 | 论坛 | 博客
  • 博客访问: 85792
  • 博文数量: 38
  • 博客积分: 350
  • 博客等级: 一等列兵
  • 技术积分: 365
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-30 09:14
个人简介

每一种技术都有其诱人之处。

文章分类

全部博文(38)

文章存档

2016年(2)

2014年(23)

2011年(13)

我的朋友

分类: PHP

2014-05-16 15:51:35

    应用:在user 模块中loginAction 登录成功后,把用户信息保存到$_SESSION之中,然后调整到其它模块。

点击(此处)折叠或打开

  1. $session = new Container('user');
  2. $session->offsetSet('uname','visitor');///此时$_SESSION['user']['uname'] === 'visitor';
  3. $this->redirect()->toRoute("app")///跳转到app/index
     跳转后$_SESSION 数据丢失,解决方法:
    1)Bootstrap 模块module.config.php添加‘cookies’ 配置信息      

点击(此处)折叠或打开

  1. return array(
  2. 'session' => array(
  3.         'remember_me_seconds' => 2419200,///保持的时间
  4.         'use_cookies' => true,
  5.         'cookie_httponly' => true,
  6.     ),
  7. );
   2) module.php::onBootstrap中添加配置session manager

点击(此处)折叠或打开

  1. public function onBootstrap($e)
  2. {
  3.     $config = $this->getConfig();
  4.     $sessionConfig = new SessionConfig();
  5.     $sessionConfig->setOptions($config['session']);
  6.     $sessionManager = new SessionManager($sessionConfig);
  7.     $sessionManager->start();
  8.     Container::setDefaultManager($sessionManager);
  9. }
阅读(1649) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~