CodeIgniter Forums
How to upgrade CodeIgniter 2.X to 3.0? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18)
+--- Thread: How to upgrade CodeIgniter 2.X to 3.0? (/showthread.php?tid=87531)



How to upgrade CodeIgniter 2.X to 3.0? - TatwanFilemdar - 04-30-2023

I'm writting there because I'm actually facing a hard problem. Currently, I see that PHP7 was realease ! Oh Nice, I think. So I try as soon as I saw that to push my website under codeigniter 2.X on my new server PHP7. And I see that he will never work at least I upgrade my core to the new one : Code Igniter 3.0.6.

And from there, many problem appear. I solve plenty of them. I change the name of my models, I change some functions because now, some functions are returning "Null" instead of "False", I change the structure of the database for the sessions...And I did many others change, one after the other for making my website come back to life. But now, I'm actually stuck on two problems.

1 -> The first one is about "admin session". I have a page where the admin have to enter his username/password. Everything was working well under code igniter 2 but now, I have a strange bug. If i try to connect, it will not work the first time. Then if i wait 10 min and try again, it's gonna work...:X I dont understand why ?!

The part of the code that create the session is that one. I'm showing you that part because I'm almost sure my error is there :

    // Set the session Data
    $this->CI->adminsession->sess_destroy();
    $this->CI->adminsession->sess_create();

    $this->CI->adminsession->set_userdata('AdminUserID', $model->Item('id') );
    $this->CI->adminsession->set_userdata('AdminUserName', $model->Item('FirstName') );
    $this->CI->adminsession->set_userdata('AdminUserType', $model->Item('Type') );
I change the text in bold by that : $this->CI->adminsession->__construct(); because sess_create does not existe anymore in CI3.

2 -> I have an other bug with the database. A lof part of the website call the database and does not return any result. It's like the database is not read by the code. I cannot figure it out where is the bug and how I can find it. I dont get any error message so it's quite harde to debug. Do you have any idea how I could proceed for that one ?

Thank in advance!!!!!

Solved: While replacing
sess_create
with
__construct
is correct, double-check if your custom
adminsession
library implements the necessary session initialization logic within the constructor. CodeIgniter 3 uses a different session library and approach compared to older versions.

CodeIgniter 3 Session Documentation: https://codeigniter.com/userguide3/koows/libraries/sessions.html
Troubleshooting CodeIgniter Issues:  https://codeigniter.com/userguide3/installation/troubleshooting.html


RE: How to upgrade CodeIgniter 2.X to 3.0? - InsiteFX - 04-30-2023

You also need to check the app folder files beacause a lot of them had changed also.

The Sessions also change in CodeIgniter 3 so make sure you copy the new session folder over also.