php - Codeigniter 3 - Session not working -
i have updated form 2.2.x 3.0.0 - following update procedure codeigniter's website http://www.codeigniter.com/userguide3/installation/upgrade_300.html
i have having real issues new session library - heres issue.
we have login section dependant on subdomain , user/pass credentials give privileges admin / reseller / client / user
in order determine correct privileges user have built customer library (location:application/library) have called session_management, library not extend core session driver/library , never has , has no extension class, library auto-loaded, prior ci 3.0.0 working fine.
first session_management __construct()
$this->ci =& get_instance(); $this->ci->load->model('users'); $this->ci->load->model('clients'); $this->ci->load->model('sessions'); $this->ci->load->driver('session'); $this->ci->load->library('password_hash'); $this->ci->load->helper('url'); $this->users = $this->ci->users; $this->clients = $this->ci->clients; $this->sessions = $this->ci->sessions; $this->session = $this->ci->session; $this->password_hash = $this->ci->password_hash;
prior ci 3.0.0 has no issues in using the
$this->ci->load->library('session')
but unknown reason (to me) have load through driver
$this->ci->load->diver('session');
- if explain why having way great.
when user submits user/pass credentials controller session/signin requested runs firstly form validation, providing successfully, session_management login method called.
$success = $this->session_management->login($this->input->post('email'), $this->input->post('password'));
in login method in session_management class bunch of sessions set using
$this->session->set_userdata() $this->session->set_userdata('user_id', 0); $this->session->set_userdata('user_name', ''); $this->session->set_userdata('client_id', 0); $this->session->set_userdata('client_administrator', 0); $this->session->set_userdata('reseller_administrator', 0);
however when var_dump() session session data has nothing , can't why is, no session data there except protected fields form config, have double checked , triple checked , working fine, sess_save_path storing session files correctly, , rest of sess configs correct.
$config['sess_driver'] = 'files'; $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; $config['sess_save_path'] = '/users/******/sites/********/tmp'; $config['sess_match_ip'] = false; $config['sess_time_to_update'] = 300; $config['sess_regenerate_destroy'] = false;
this development website on local os x imac, prior ci 3.0.0 working fine.
just add before reply's saying "you need use"
$this->load->library('session');
i have "had" load driver, don't have choice, have read documentation , have seen how initialise session library - http://www.codeigniter.com/userguide3/libraries/sessions.html#initializing-a-session
if attempt load library
$this->load->library('session')
this get
a php error encountered severity: notice message: undefined property: session::$session filename: libraries/session_management.php line number: 38
for ref: line 38 is:
$this->session = $this->ci->session;
this after trying load session library
$this->ci->load->library('session');
also add message re: database sessions / file session. database sessions first option, have revamp database columns , indexes suit ci 3.0.0 documentation mentions , session , storing in database table when change config use database, reading performance differences between file sessions against database sessions under high load, file sessions out perform database session , since website / platform creating under high load, database sessions aren't way forward.
as note: website runs under subdomain.domain.*** structure subdomain registered company name upon company registration i.e
mycompany.mywebsiteurl.com anothercompany.mywebsiteurl.com
as mention - prior update ci 3.0.0 working fine.
might add: have checked log files, running tail -f live log updates - , don't see log issues.
any help, information or possible put me in right direction appreciated.
i have posted on ci forum: http://forum.codeigniter.com/thread-62262.html
a fresh copy of ci 3.0.0 necessary files , configs transferred across didn't solve problem/issue.
what seems whole cause of problem fact had controller call sesssion.php named same driver file.
when ci (codeigniter) calls
$this->load->library('session')
there few checks done before ci knows want load ci_session class ... class_exists('session') returns true , stops there in order avoid fatal error.
hope helps others too.
Comments
Post a Comment