[eluser]kirilisa[/eluser]
Hi folks,
I just have a quick question on the viability of codependent libraries. Let's say I have two libraries that I am autoloading: session and auth. No matter what I do, I will never be able to access them each from each other, no?
e.g. if I wrote
Code:
//session.php
$this->ci =&get;_instance();
$this->ci->load->library('auth');
AND
//auth.php
$this->ci =&get;_instance();
$this->ci->load->library('session');
it clearly doesn't make sense as that basically represents an infinite loop of the libraries' loading each other. The CI result is that it doesn't break, but the second library (auth) never gets session loaded. i.e. I can set up one of them to access the other one, but not set it up so that they can access each other.
I'm sure you wonder why I'm asking this so I will tell you. My auth class necessarily uses the session a few times (for access checking, to get a stored userId to look up page access from the DB, etc., and to point to sess_destroy from its logout method) - I don't really see any way around this. The reason I was thinking of making session access auth was for use of a particular method - $auth->log_logout(), where I was trying to log a user's logout date/time even if his logout was indirect in that it resulted from a session expiration. I can of course just write a second log_logout method within session.php but it will be redundant.
However, given that I am trying to log peoples' logouts whether via clicking 'logout' or due to session expiration, I can't think of any really clean way to do it.
Anyway else ever tried to implement something of this sort?
Thanks!