Losing CodeIgniter Sessions
I had a scenario earlier today where I was setting a session using the CodeIgniter Session library, it was being set fine but then as soon as I navigated to another page it was being lost.
After much research and testing it turns out it was due to the fact my session name contained an underscore. Removing the underscore then resolved the issue:
$this->session->set_userdata('my_session_name', 'My Session Data');
$this->session->set_userdata('mysessionname', 'My Session Data');
I’m not sure why this occured and I’m suprised it’s not mentioned anywhere in the CodeIgniter user guide. Anyway, I hope that this helps someone who is experiencing similar problems with regards to losing session data.