views:

28

answers:

2

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.

A: 

This should work:

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

You should use the session provided by CodeIgniter instead of mixing in native sessions.

halfdan
+1  A: 

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

Paul
Oh, geez... I'm used to doing that up-front when I build a project from scratch. Didn't think of doing that in CI. I just put a session_start() in the single controller function that I needed it, instead of putting it in CI globally.
mogmismo