Replacing CodeIgniter’s session by PHP’s Native Session

codeigniterFor last 8 months, I have been working on a web application. We are developing the application based on CodeIgniter framework. In our project there are normal web version and mobile view version. Some days ago we noticed that, some people can’t login their account via mobile version though there username & password are correct. After debugging and digging the problem we found that in iPod Touch 2G/3GS Safari browser, this problem is happening.

We are using CodeIgniter’s built in session library and that is different than normal PHP’s session. We found that for each visit of the user, the server can’t track the session and regenerating new session id each time. Very weird situation for us. As we coded all over based on CodeIginter’s session library’s function so its not optimal solution for us to remove the codes and use PHP’s native session. Because in that case there is high possibility to generate new bugs. After lots of searching in the net at last we found a wrapper class for CodeIgniter.

This wrapper class is named Native session . It uses the same functions name like CodeIgniter’s Session class, but it used PHP’s native session on the back end. As our project is running on Dedicated Server so we are not worried about the session security. We replaced CodeIgniter’s Session class by this Native session  class and it solved our problem.

So if you’re facing this type of session related problem by using CodeIgniter’s Session library, you can use the  Native session library to fix the problem. Hope it helps.

About mahmud ahsan

I'm a Technology Enthusiast & ZCE. My primary fields of work are web & iPhone application development. I'm founder of iThinkdiff.net - a small iOS application development studio and Thinkdiff.net - a familiar technical blog. My passion is programming, software & game development. To know more about me visit my portfolio page.

, , ,

5 Responses to Replacing CodeIgniter’s session by PHP’s Native Session

  1. M.M.H.Masud August 24, 2011 at 12:56 am #

    Nice one. Very much helpful. i keep this in my bookmarks.

  2. Manoranjan August 24, 2011 at 4:07 pm #

    I need code as facebook like button. So that a users clicks the button and logins, then he will be able to hit a count and like. So in similar way i need a button code. If anyone is interested, please let me know. m.badajena@gmail.com

  3. Nithin K Varrier December 7, 2011 at 4:35 pm #

    Thanks Ahsan. Very helpful article. I’m facing the same problem. thank you so much

  4. Carlson Orozco December 25, 2011 at 10:40 pm #

    I got the same problem… Thanks Ahsan for this article.

  5. andre3 February 9, 2012 at 5:15 am #

    Thank you :D saved me alot of problems hehe

Leave a Reply