Welcome Guest, Not a member yet? Register   Sign In
Session issue
#1

[eluser]bhakti.thakkar[/eluser]
Hello,
I have three applications of CI working on same domain. The problem is if all three are running parallel and if i log of from one, i automatically log off from the other two as well. So that means that the sessions is getting unset or killed
I am using user defined sessions library
Below are my settings in config.php for sessions and of course the name (encryption_key , sess_cookie_name , cookie_prefix) are different for all three

Code:
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| If you use the Encryption class or the Sessions class with encryption
| enabled you MUST set an encryption key.  See the user guide for info.
|
*/
$config['encryption_key'] = "bits_encryption_key_Gg2F5";

/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'session_cookie_name' = the name you want for the cookie
| 'encrypt_sess_cookie' = TRUE/FALSE (boolean).  Whether to encrypt the cookie
| 'session_expiration'  = the number of SECONDS you want the session to last.
|  by default sessions last 7200 seconds (two hours).  Set to zero for no expiration.
| 'time_to_update'        = how many seconds between CI refreshing Session Information
|
*/
$config['sess_cookie_name']        = 'bits_sessions';
$config['sess_expiration']        = 3600;
$config['sess_encrypt_cookie']    = TRUE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']        = 'sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 300;

/*
|--------------------------------------------------------------------------
| Cookie Related Variables
|--------------------------------------------------------------------------
|
| 'cookie_prefix' = Set a prefix if you need to avoid collisions
| 'cookie_domain' = Set to .your-domain.com for site-wide cookies
| 'cookie_path'   =  Typically will be a forward slash
|
*/
$config['cookie_prefix']    = "bits";
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";

/*
#2

[eluser]WanWizard[/eluser]
Make sure your cookie domain and path are set properly.

If they're all defined like this, they overlap, so all three application use the same cookie. Are they all using the same sessions table as well, you do you have separate databases for the three applications (in which case you have a session_id issue as well).
#3

[eluser]bhakti.thakkar[/eluser]
How can they overlap even if the names of sessions, cookies are different for all the three? I am not using session tables to store sessions. I am using user defined session library.
#4

[eluser]WanWizard[/eluser]
Then at least you will have to post your session library code. How do you expect us to help you if you're using custom code and we don't have a clue what it does?

With regards to overlap, if you have three applications that all use the cookie definition as you posted, the path and domain for all three are the same. So unless your unknown custom code does something smart there, all tree applications are going to create (and delete) the same cookie. Which would explain why a logout from one application (which deletes the cookie) would also force a logout from the other applications.

If you have http://www.example.org/app1 and a http://www.example.org/app2. make sure you set your cookie domain to 'www.example.org', and the path to '/app1' for your first application, and '/app2' for your second application. This way cookies stay restricted to your application.




Theme © iAndrew 2016 - Forum software by © MyBB