如何从CodeIgniter内部访问标准PHP会话数据 [英] How to access standard PHP session data from inside CodeIgniter

查看:107
本文介绍了如何从CodeIgniter内部访问标准PHP会话数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Codeigniter项目,我正在使用,并使用CI会话(存储在一个数据库),但我需要检查另一个$ _SESSION中的变量从另一个应用程序(在同一个cookie域) ,但是当我尝试,从CI控制器使用本地PHP会话以获得这一点信息($ _SESSION ['blah']),看起来像CI剥离了全局$ _SESSION数据。任何人都知道我可以得到它的方式吗?我想基本上做这样的事情(当然有更多的错误检查):

  if(isset _SESSION ['user_id'])){
$ this-> session-> set_userdata('usermap',$ _SESSION ['user_id']);
}

任何帮助将不胜感激。

index.php?中加入 session_start() $ c>


I've got a Codeigniter project I'm working on, and using the CI Sessions (stored in a DB), but I need to check for a variable in another $_SESSION from another application (in the same cookie domain), but when I try, from the CI controller to use native PHP sessions to get this one bit of info ($_SESSION['blah']), it looks like CI is stripping out that global $_SESSION data. Anyone know a way I can get at it? I'd like to basically do something like this (with a little more error checking of course):

if (isset($_SESSION['user_id'])){
      $this->session->set_userdata('usermap', $_SESSION['user_id']);
}

any help would be appreciated.

解决方案

Have you put session_start() in your index.php?

这篇关于如何从CodeIgniter内部访问标准PHP会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆