CodeIgniter Forums
Session problem when upgrade 2.x to 3.0.x - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Session problem when upgrade 2.x to 3.0.x (/showthread.php?tid=63262)



Session problem when upgrade 2.x to 3.0.x - trinh.thanh.long - 10-12-2015

Excuse me, everyone. I met an issues and need all your helps.

I upgraded CI from 2.1.4 to 3.0.1 and Session makes me crazy. I implemented "Remember me" function with the below code in CI 2.1.4.

Code:
           if ($remember) {
               $this->session->set_userdata('new_expiration',60 * 60 * 24 * 31);
               $this->session->set_userdata('new_sess_expire_on_close',FALSE);
               $this->session->sess_update();//it available in 2.1.4 but in 3.0.x
           }else{
               $this->session->unset_userdata('new_expiration');
               $this->session->unset_userdata('new_sess_expire_on_close');
               $this->session->sess_update();//it available in 2.1.4 but in 3.0.x
           }

After upgrading to 3.0.1, the sess_update() function has been removed from Session class. Therefore, the error occurs. Of course the error does not appear in case I comment
Code:
$this->session->sess_update();
, but "Remember me" function has been failed.
I have searching for a while but cannot see the equivalent function for
Code:
sess_update();
in CI 3.0.x.

Does anyone has ideas about it.

Thanks and regards!


RE: Session problem when upgrade 2.x to 3.0.x - mwhitney - 10-13-2015

Did you try it without the sess_update() call? As far as I can tell, it should no longer be necessary.


RE: Session problem when upgrade 2.x to 3.0.x - trinh.thanh.long - 10-13-2015

What do you means, mwhitney? Which function I could use without the sess_update()?


RE: Session problem when upgrade 2.x to 3.0.x - mwhitney - 10-14-2015

Just take sess_update() out of your code (it's no longer a valid function anyway) and see if your code works properly without it.

If you really need similar functionality to sess_update(), the closest thing I can think of is sess_regenerate().


RE: Session problem when upgrade 2.x to 3.0.x - trinh.thanh.long - 10-14-2015

Thanks for your response, mwhitney.

As I described above, when I took sess_update() out of my code, It runs without errors but my function "Remember me" failed. I set
Code:
$config['sess_expiration'] = 0;
in config file, it means cookies will be invalid when closing the browser. When
Code:
$remember
variable is true (code above), I want to update sess_expiration to 1440 (for ex.). How I can do this?


RE: Session problem when upgrade 2.x to 3.0.x - trinh.thanh.long - 10-15-2015

I've fixed the problem. Thanks for your response!