Welcome Guest, Not a member yet? Register   Sign In
[Workaround found] CodeIgniter 3.0 cannot access native $_SESSION
#4

(04-14-2015, 07:21 AM)gofrendi Wrote:
(04-14-2015, 07:15 AM)RWCH Wrote: Just a guess:

session_start() starts a new session or resumes an existing session". By doing another page request without calling session_start you will loose you session. You MUST call session_start() to resume your session. Why do you call session_start()?

In CodeIgniter it is sufficient to use $this->load->library('session'); You session will be available with every page request and you can access it using $this->session.

I think var_dump($_SESSION); and var_dump($this->session); will give you the same result. However I never checked it and cannot check it now.

I have call session_start() in my external script:


PHP Code:
<?php
    if
(!isset($_SESSION)){
 
       session_start();
 
   }
 
   var_dump($_SESSION); 


Yes var_dump($_SESSION) and var_dump($this->session->all_userdata()) will give the same result, but it has nothing to do with my problem.

My problem is:

$_SESSION in my non-codeigniter php application is different from $_SESSION in codeigniter application.
Thus Codeigniter and non-codeigniter php application cannot share session.

You could do a check when the user enters your CI application.
If you have created your sessions in the other app with the normal $_SESSION functionality you could just do something like this when the user enters the CI app:

PHP Code:
if(isset($_SESSION['whatever'])) {
 
   # add it to the CI session
 
   $this->session->userdata....


You could also do it the other way around. Just make sure to validate them when passing them between the scopes.
Reply


Messages In This Thread
RE: CodeIgniter 3.0 cannot access native $_SESSION - by Northize - 04-14-2015, 07:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB