I have this problem, and I don't know how to solve it.
Message: Undefined property: start_up::$uri
Filename: libraries/start_up.php
Line Number: 25
Fatal error: Call to a member function segment() on a non-object in C:\Program Files\wamp\www\sooq\application\libraries\start_up.php on line 25
The line 25
is the following code:
if ($this->CI->config->item('close') == 1 && $this->uri->segment('1') != 'Admin' && !$this->ion_auth->is_admin()) {
redirect(base_url() . 'home/close', '
}
Also the following is the method that has the problem:
function _init() {
$this->CI->load->model('start_up_model');
foreach ($this->CI->start_up_model->get_config()->result() as $config) {
$this->CI->config->set_item($config->Var_Name, $config->Var_Value);
}
/* ---->>>new_settings */
$setting = $this->CI->start_up_model->get_newsetting();
foreach ($setting as $key => $value) {
$this->CI->config->set_item($key, $value);
}
if ($this->CI->config->item('close') == 1 && $this->uri->segment('1') != 'Admin' && !$this->ion_auth->is_admin()) {
redirect(base_url() . 'home/close', 'refresh');
}
if ($this->CI->session->userdata('lang')) {
$this->CI->lang->load($this->CI->session->userdata('lang'), $this->CI->session->userdata('lang'));
$this->CI->session->set_userdata('lang', $this->CI->session->userdata('lang'));
if ($this->CI->session->userdata('year')) {
$this->CI->session->set_userdata('year', $this->CI->session->userdata('year'));
} else {
$this->CI->session->set_userdata('year', '2013');
}
} else {
$this->CI->lang->load('arabic', 'arabic');
$this->CI->session->set_userdata('lang', 'arabic');
if ($this->CI->session->userdata('year')) {
$this->CI->session->set_userdata('year', $this->CI->session->userdata('year'));
} else {
$this->CI->session->set_userdata('year', '2013');
}
}
}
$this->CI
Is defined in this way:
$this->CI = &get_instance();
As you're using CI instance in your custom library, all native libraries, including the URI class, have to be called via instance. You're doing it right everywhere in your code, except when calling a URI class. So instead of
$this->uri->segment('1')
Do:
$this->CI->uri->segment('1')