I have set my codeigniter website to be a web app using Apples documentation. https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
It works well, but none of my sessions are saving when they switch between apps.
$this->session->set_userdata('logged_in', true);
$this->session->set_userdata('id', $data['id']);
$this->session->set_userdata('role_id', $data['role_id']);
I found a good article about this but don't know how this would look using codeigniter. Maintaining a PHP session on an iPhone web app
Another approach is to use database sessions, please enable it in application/config/config.php
by $config['sess_use_database'] = TRUE;
I mostly use database session because of following fact:
Note: Cookies can only hold 4KB of data, so be careful not to exceed the capacity. The encryption process in particular produces a longer data string than the original so keep careful track of how much data you are storing.
Continue; creating table ci_sessions
CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(45) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id),
KEY `last_activity_idx` (`last_activity`)
);
And you are good to go, use the code you provided in question, session is saved in database.