Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 581471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:34:56+00:00 2026-05-13T14:34:56+00:00

I’m thinking about using CodeIgniter for a new project. I was reading the user-guide

  • 0

I’m thinking about using CodeIgniter for a new project. I was reading the user-guide for CI and I noticed a few things. In all their examples, they seem to put all the logic in the Controller and just use the model to get and set data. I like to put all my logic in my Model.

Are all of their functions universal to all 3 parts (model, view, and controller) or will there be problems if trying to do logic in the model as opposed to the controller.

Also, are all variables accessible to all 3 parts (model, view, and controller). If I wanted to know if a user was logged in within the view, would I have to pass that information to the view from the controller or is it already accessible within the view?

Also, I noticed that session data is stored within cookies, even though they are encrypted. Is the encryption safe enough to use, beause im more used to using sessions. Also, how long are these cookies stored by default? I was a little confused about that part, if anybody can clear that up.

If you have any other tips to help my learning this new framework, I would appreciate it.

Thanks

EDIT: I like to use Fat Models and skinny controllers, so that I can use the same functions in more than one place.

Just read about Kohana, I think I’ll look more into that

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:34:56+00:00Added an answer on May 13, 2026 at 2:34 pm

    they seem to put all the logic in the Controller and just use the model to get and set data.

    CodeIgniter expects very little logic in its models, and instead gives you a very dumb SQL wrapper for returning simple arrays of POD types to represent your data. It even puts a lot of validation code into the controllers, which (in my opinion) is incorrect and repetitive. I’ve rolled my own solution for Rails-style in-model validation and dynamic find method, allowing things like

    // inside model: 
    // username must be 8 to 25 chars long
    $this->validates_length_of('username', 8, 25);
    
    // dynamically handled via __call()
    $this->User->find_first_by_username('john'); // Return object or null
    $this->User->find(); // select *
    $this->User->find_by_group('admin'); // return 0 or more records
    

    but AFAIK there isn’t any built-in way of doing similar things with CodeIgniter.

    Also, are all variables accessible to all 3 parts

    No; you have to manually pass your variables from your controller to your view, and there is no sharing of variables with models/controllers or models/views.

    I believe the method suggested by CodeIgniter:

    <?php
    
    function users() {
      $data['users'] = $this->User->find(); 
    
      // must use $data['users'] for controller logic; verbose and annoying
    
      $this->load->view('users/index', $data); // $users defined for view
    }
    
    ?>
    

    can be improved by using PHP’s compact keyword:

    <?php
    
    function users() {
      $users  = $this->User->find(); 
    
      // now we can use $users more easily
    
      $this->load->view('users/index', compact('users'));
    }
    
    ?>
    

    I noticed that session data is stored within cookies

    CodeIgniter can store session data in a database; see $config['sess_use_database'] in config/config.php. There are other config settings in there that pertain to the lifetime of the session cookie.

    I’m inclined to say that the only thing CodeIgniter does well is their documentation, read more about session configuration and their implemntation of active record (really a language-independant SQL wrapper which has nothing to do with the Active Record pattern)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 418k
  • Answers 418k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When you have Echo e2=e1; you make it so both… May 15, 2026 at 10:04 am
  • Editorial Team
    Editorial Team added an answer Regexes can support end-of-string anchoring, you know. (See this Javadoc… May 15, 2026 at 10:04 am
  • Editorial Team
    Editorial Team added an answer It's pretty common for people to tell you that any… May 15, 2026 at 10:04 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.