title: my project setup in codeigniter, need some tips on how to progress design-wise
body: <p>for the most part i think my code is messy right now possibly because iam not really used to CI. I currently have one controller called 'user' which i will show below.  in this controller
  I have methods such as login,logout etc. standard enough stuff in here like creating a session when the user logs in and destroying it when a user logs out. iam also tracking time as the system mimics a 'check in' system to get a users hours worked. the next part of the project requires access to the 'clients' tablem in the database that a user works with and is going to display some info about this client when a button is pressed, the clients themselves do not use this system but information about them needs to be viewed. Iam just wondering should i continue to add to my current controller and model or setup seperate classes next,seems to me the controller is already relatively big? here is my controller code.</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class User extends CI_Controller {
  
      var $loggedin = FALSE;
      var $cdata;
  
      function __construct()
      {
           parent::__construct();
           $this-&gt;load-&gt;model("dbaccess");
  
          $this-&gt;cdata =array( "warning" =&gt; "","email"=&gt; "","password"=&gt; "","logintime"=&gt;"","start"=&gt;"","end"=&gt;""
              ,"diff"=&gt;"","totalhours"=&gt;"","dis"=&gt;$this); 
  
      }
  
  
  public function index()
  {
      if($this-&gt;session-&gt;userdata('email'))
      {
           $this-&gt;load-&gt;view('carerview',$this-&gt;cdata);
      }
      else
      {
          $this-&gt;load-&gt;view('mainview',$this-&gt;cdata);
      }
  
  }
  
  
  public function login()
  {
          //get posted data. check if what is posted is in db.
          // if it is set loggedin=true + redirect to carer page + save data in session.        //get posted data. check if what is posted is in db.
  
          if(isset($_POST['email'])  )
              {$this-&gt;cdata['email'] = $_POST['email'] ;}
              else
              {$this-&gt;cdata['email'] ="";}
          if(isset($_POST['password']))
              {$this-&gt;cdata['password'] = $_POST['password'];}
              else
              {$this-&gt;cdata['password'] ="";}
  
  
          if($this-&gt;session-&gt;userdata('email'))
              {       
                  $this-&gt;loggedin = true;
              }
          else
              {
                  $this-&gt;loggedin = $this-&gt;dbaccess-&gt;check_input($this-&gt;cdata['email'],$this-&gt;cdata['password']);
              }
  
  
  
  
      if($this-&gt;loggedin === TRUE &amp;&amp; !$this-&gt;session-&gt;userdata('email'))
          {
  
              $this-&gt;start_session();
  
              if(!$this-&gt;dbaccess-&gt;get_date_entry($this-&gt;session-&gt;userdata('email'),date("Y-m-d")))
              {
                  $data =     array("email"=&gt;$this-&gt;session-&gt;userdata('email'),"date"=&gt;date("Y-m-d"),
                  "hours"=&gt;"0","starttime"=&gt;date("Y-m-d     H:i:s",$this-&gt;session-&gt;userdata('last_activity')));
                  $this-&gt;dbaccess-&gt;insert_daily_row($data);
              }
  
              $this-&gt;load-&gt;view('carerview',$this-&gt;cdata);
          }
  
      else if ($this-&gt;loggedin === TRUE &amp;&amp; $this-&gt;session-&gt;userdata('email'))
          {
              $this-&gt;cdata['totalhours']= $this-&gt;session-&gt;userdata('totalhours');
              $this-&gt;cdata['logintime']= $this-&gt;session-&gt;userdata('last_activity');
              $this-&gt;load-&gt;view('carerview',$this-&gt;cdata);
  
          }
  
      else
          {
              $this-&gt;session-&gt;unset_userdata('last_activity');
              $this-&gt;cdata['warning']="Check failed ! Please try again";
              $this-&gt;load-&gt;view('mainview',$this-&gt;cdata);
          }
  }
  
  
  private function start_session()
  {
  
      $this-&gt;load-&gt;library('session');
      $this-&gt;session-&gt;set_userdata('email',$this-&gt;cdata['email']);
      $this-&gt;cdata['totalhours']= $this-&gt;dbaccess-&gt;get_hours_by_date
      ($this-&gt;session-&gt;userdata('email'),date("Y-m-d",$this-&gt;session-&gt;userdata('last_activity')));
      $this-&gt;session-&gt;set_userdata('totalhours',$this-&gt;cdata['totalhours']);
  }
  
  
  
  
  
  
  private function calculatedifference($starttime,$endtime) // delete checkin time from checkouttime
  {
  
      $diff=  abs(strtotime($starttime) - strtotime($endtime));
      $this-&gt;cdata['diff'] = date("H:i:s",$diff);
      $this-&gt;cdata['start'] = date("Y-m-d H:i:s", strtotime( $starttime)+(1 * 3600));
      $this-&gt;cdata['end']= date("Y-m-d H:i:s", strtotime($endtime) +(1 * 3600));
      return  date("H:i:s",$diff);
  
  }
  
  
  public function isLoggedIn()
  {
      return $this-&gt;loggedin;
  }
  
  
  
  public function logOut()
  {
      // update total hours and update checkout time.
  
      if($this-&gt;session-&gt;userdata('email')){
      $hours=$this-&gt;calculatedifference(date("Y-m-d H:i:s",$this-&gt;session-&gt;userdata('last_activity')),date("Y-m-d H:i:s"));
      $data =array("endtime"=&gt;date("Y-m-d H:i:s"),"hours"=&gt;$hours,"email"=&gt;$this-&gt;session-&gt;userdata('email'),"date"=&gt;date("Y-m-d"));
      $this-&gt;dbaccess-&gt;update_daily_row($data);}
  
          $this-&gt;load-&gt;view('mainview',$this-&gt;cdata);
          $this-&gt;session-&gt;sess_destroy();
  }
  
  
  public function admin()
  {
      $this-&gt;load-&gt;view('adminpage',$this-&gt;cdata);
  }
  
  
  
  
  
  
  
  }
  </code></pre>