Welcome Guest, Not a member yet? Register   Sign In
Improving code
#1

[eluser]ninjayan[/eluser]
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
Code:
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 -_- )


Messages In This Thread
Improving code - by El Forum - 10-13-2012, 10:38 PM
Improving code - by El Forum - 10-13-2012, 11:08 PM
Improving code - by El Forum - 10-13-2012, 11:22 PM
Improving code - by El Forum - 10-13-2012, 11:32 PM
Improving code - by El Forum - 10-13-2012, 11:44 PM
Improving code - by El Forum - 10-13-2012, 11:45 PM
Improving code - by El Forum - 10-13-2012, 11:52 PM
Improving code - by El Forum - 10-14-2012, 12:15 AM
Improving code - by El Forum - 10-15-2012, 03:31 AM
Improving code - by El Forum - 10-15-2012, 03:39 AM
Improving code - by El Forum - 10-16-2012, 02:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB