CodeIgniter Forums
Multi application and Session - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Multi application and Session (/thread-3503.html)



Multi application and Session - El Forum - 10-06-2007

[eluser]Tacos[/eluser]
Hello,

I would like to know if it's possible to share session information between multiple CodeIgniter application on the same root ?

Thanks


Multi application and Session - El Forum - 10-06-2007

[eluser]llbbl[/eluser]
Yes that is the definition and purpose of PHP sessions.

http://www.w3schools.com/php/php_sessions.asp


Multi application and Session - El Forum - 10-07-2007

[eluser]Tacos[/eluser]
Ok so I have to use native php session because when I use CodeIgniter session all my session information are reinizialized when I switch between two CodeIgniter application ...

PS : I use multi application with the same CodeIgniter system


Multi application and Session - El Forum - 10-07-2007

[eluser]Michael Wales[/eluser]
You can use the same session as long as they are hosted on the same domain and your config.php settings reflect that.


Multi application and Session - El Forum - 10-07-2007

[eluser]Tacos[/eluser]
This is my cookie on App "A" :

Code:
Name : intranet
Value : session_id -> "5d507347f3ae2d246adfe1ad73613db1"
Domaine (host) : localhost
Chemin d'accès (path) : /
Sécurisé : non
Expire le : Sun, 07 Oct 2007 12:59:41 GMT

This is my cookie on App "B" :

Code:
Name : intranet
Value : session_id -> "556e5072430eff34a716804ca7902d49"
Domaine (host) : localhost
Chemin d'accès (path) : /
Sécurisé : non
Expire le : Sun, 07 Oct 2007 12:59:41 GMT

Sessions id are different between App A and App B ...

When i reload my App A page the session id become the same than the App B session ...

After that it works correctly, but when I switch for the first time to App B session is reinizialized

Localhost can cause problems because it's not a real domain ? I don't have domain on my test machine ...


Multi application and Session - El Forum - 10-07-2007

[eluser]llbbl[/eluser]
Your doing testing this locally? I have always been a big fan of test.example.com or what have you for testing.


Multi application and Session - El Forum - 10-08-2007

[eluser]Tacos[/eluser]
This is all good now !

I recreate two new App with same config file and it works perfectly.

Thanks a lot !

Bye


Multi application and Session - El Forum - 10-09-2007

[eluser]PogiNate[/eluser]
If your two applications are on the same server, but not in the same directory, can you still use the CI sessions instead of the vanilla PHP sessions? How did you get that to work? I've just been asked to come up with a solution of this type and I would appreciate any help anyone can give!

Thanks!


Multi application and Session - El Forum - 10-10-2007

[eluser]Tacos[/eluser]
@PogiNate

I don't use the CodeIgniter user guide method for multi application but this one instead.

If you want to use CodeIgniter sessions in a multi application site you only have to use same cookies and sessions variables in each config.php file of each application :
Code:
$config['sess_cookie_name']
$config['sess_expiration']
$config['sess_match_ip']
$config['sess_match_useragent']

$config['cookie_prefix']
$config['cookie_domain']
$config['cookie_path']

If you want to use encryption the key must be the same :
Code:
$config['encryption_key']
$config['sess_encrypt_cookie']


Hope it can help you.


Multi application and Session - El Forum - 10-12-2007

[eluser]PogiNate[/eluser]
Well that seems simple enough. Thank you!