Hi everyone!
So it’s me again. Today I want to make my code cleaner and less redundant. So this is my current code.
Controller
public function dashboard() {
if ($this->session->userdata('is_logged_in')) {
$this->load->view('dashboard');
}else {
redirect(base_url());
}
}
public function account_settings() {
if ($this->session->userdata('is_logged_in')) {
$this->load->view('account_settings');
}else {
redirect(base_url());
}
}
——-
So you notice that I do checking if the session ‘is_logged_in’ is set. I do this in almost all of my functions. Can you give me other ways to do it? I mean to stop using if statement and just call a function to check if it is set?
(I have trouble explaining -_- )
