Welcome Guest, Not a member yet? Register   Sign In
Session serialized data... kinda? Dont understand the format
#13

The name of the class declared in the session library is CI_Session, so you can either remove the check for 'session' that wraps your call to load->library('session') or change it to check for 'CI_Session'. Also, you may want to use class_exists('whatever', false) instead of in_array('whatever', get_declared_classes()), because class_exists() is case-insensitive, but in_array is not (and get_declared_classes() is going to return the class names using the same case used when they were declared).

I'm not sure how well PHP can handle circular dependencies like this, but it's clearly something that should be avoided, anyway. I would probably avoid using the session in the model's constructor, but you'll probably have to make some significant changes in the model to ensure it's initialized properly.

On a somewhat unrelated note, CI_Model allows you to reference the CI_Controller singleton (returned by get_instance()) through $this, so, unless you're really fond of the static syntax, there's no need for the self::$CI =& get_instance() (you can also use $this->load->library(), $this->session->userdata(), $this->session->session_id, etc.) and what you've defined as self::$db is already available in the model as $this->db.
Reply


Messages In This Thread
RE: Session serialized data... kinda? Dont understand the format - by mwhitney - 08-25-2015, 08:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB