I’m developing a php application using CodeIgniter2, this application resides in:
/public_html/community/
-application
-system
-index.php
This application has its own My_Session library (extending from native CI_Session library). Well, everything goes fine here. But, I want to create a Portal/Frontpage at the root directory, for this porpusee I have installed another CI2 application:
/public_html/
-application
-system
-index.php
-community/ (here resides the another CI2 installation)
What I have tried to do is “share” the Session library from community to root using the method $this->load->add_package_path() from Loader class, as below:
$this->load->add_package_path('/public_html/community/application/');
$this->load->library('Session');
The problem here is that the Loader class load the Session library from the root system instead package library (community/application/libraries). Did you know how can I deal with it? or if you know a another way to share the Session Library.
Edit
Here is where my session library resides:
/public_html/community/application/libraries/My_Session.php
Well, I got with help of this topic: Session sharing between two CodeIgniter Applications. And the final snipped is:
Add the application package
$this->add_package_path(‘/public_html/community/application/’);
Load the Session library from Root CI application
$this->library(‘session’);
Load the library from the application package (community).
The magic here is that this class extends from Session class previously
loaded at point 2.
$this->library(‘MY_Session’, ”, ‘csession’); //rename the object to avoid name conflict
Now, in my root application controllers I can do: