Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter questions: native PHP sessions, code flow, layout issues?
    text
    copied!<p>I am just getting started with CodeIgniter, and I am trying to hash out my regular modules/functions to get them working properly within the MVC framework. I have a few specific questions for anyone who has a strong CodeIgniter background:</p> <p><strong>SESSIONS</strong></p> <p>The CodeIgniter session stores session data on the client side in a cookie, which just isn't going to work for me. I know there are a few replacements for it, or I could build my own library/helper; but I just don't see any benefit over just using <code>$_SESSION</code>.</p> <p>If I just use <code>$_SESSION</code>, will I have any problems with the rest of the framework? Does any other part of the framework depend on using the CodeIgniter session?</p> <p>I feel a bit weird about stepping outside the framework for something so basic, but I am pretty comfortable with plain PHP. I am basically just looking to use CodeIgniter for MVC, and to enforce a more modular aspect for my projects.</p> <p><strong>CODE FLOW &amp; CONFIG</strong></p> <p>I have a few config items that need to be done before almost anything else. </p> <p>For example, say I have a constant <code>APP_LIVE</code>, which is set true/false based on the name of the current server. This has to happen really early as paths, error reporting, the CodeIgniter system, and application folders, etc. will be set based on it.</p> <p>The problem is that the <code>system_folder</code>, and <code>application_folder</code> (which will be set based on which server the code is running on) are set first thing in the <code>index.php</code> file, before any of the configs have loaded.</p> <p>Also, I have a functions that check for things in the URL, and may redirect before the page ever loads. For example, some pages need to enfore the presence of <code>www.</code> in the URL (for SEO), track affiliates, visitor sources, marketing flags, etc.</p> <p>Where is the best place to put things like this that have to happen really early? I know there is a config file, an autoload file, a constants file, etc., but those are too late for some items. Is it a bad practice to simply put these things into the top of the main <code>index.php</code> file, or to make an include there to a global config file? Again, I feel like I am stepping outside the framework, and wonder if I'm just doing that because I don't have a solid understanding of it yet?</p> <p><strong>LAYOUT / HEADER FOOTER</strong></p> <p>Like most people, I have a top header, navigation, footer, etc. I am used to just having them in files, which are included into my page template. I believe I can do that the same way by just making them views and including them into my main page view. Is that the best way to go? Some of them need a bit of data; like what page they are on for the navigation, etc. What's the best way to handle navigation, shared header/footer, etc.?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload