[Workaround found] CodeIgniter 3.0 cannot access native $_SESSION |
(04-14-2015, 07:37 AM)Northize Wrote:(04-14-2015, 07:21 AM)gofrendi Wrote:(04-14-2015, 07:15 AM)RWCH Wrote: Just a guess: Have you try it? I don't think it will work. First, you have $_SESSION['whatever'] from other application. Now, when you do $this->load->driver('session'), there will be no $_SESSION['whatever'] When you load session library, and use "files" as driver, $_SESSION in the next code will be totally different. $_SESSION will be an alias to codeigniter session, and it will be totally off. The documentation (http://www.codeigniter.com/userguide3/li...ssion-data) said that these script are the same: PHP Code: $name = $_SESSION['name']; But it miss something important. Once you load session library, you will never able to access the original native php session anymore. I think I have mention it, but I'll say it again: I have a controller: application/controllers/welcome.php PHP Code: <?php I have another PHP file: x.php PHP Code: <?php I access this url : http://localhost/index.php/welcome. It yield this: array (size=1) '__ci_last_regenerate' => int 1429025329 I access this url : http://localhost/x.php. It yield this: array (size=0) empty This mean that $_SESSION in welcome.php is different from $_SESSION in x.php The $_SESSION should always be the same. Thus, CodeIgniter and any other application which is written in plain PHP cannot share session. This behavior is unexpected, or do you think otherwise? Or do you have a different result from mine? Please at least try the example I provide before rush to comment. I have no problem with codeigniter 2.1.4 and 3.0 dev. This problem only occurred with CodeIgniter 3.0. |
Welcome Guest, Not a member yet? Register Sign In |