CodeIgniter Forums
CodeIgniter Session Sharing between two apps - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: CodeIgniter Session Sharing between two apps (/thread-46637.html)

CodeIgniter Session Sharing between two apps - El Forum - 11-09-2011

Hello All,

I have two apps: &

I setup virtual hosts to serve them from different folders. Both are reference to the same database. I am using ion_auth.

Now my config files for both apps that I want to share the session is:

$config['sess_cookie_name']  = 'myapp';
$config['sess_expiration']  = 0;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = TRUE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name']  = 'default_ci_sessions';
$config['sess_match_ip']  = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

When I do some quick tests it looks like both of the apps are using EXACTLY the same session (I have the profiler enabled)

I am using the same chrome browser to log into the first app. The second app has no login and I simply want to use the session that was made from the first app after the user logged in.

It works fine and exactly like expected for the first few minutes. After few mins, I am trying to test by randomly logging in and logging out and accessing app2 to see the session info.

Suddenly, it looks like both the apps have different session ids.

Any thoughts on what I am missing? How do I make both apps to use the same exact session id?

Thank you.