Welcome Guest, Not a member yet? Register   Sign In
Multi application and Session
#1

[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
#2

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

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

[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
#4

[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.
#5

[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 ...
#6

[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.
#7

[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
#8

[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!
#9

[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.
#10

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




Theme © iAndrew 2016 - Forum software by © MyBB