![]() |
Bunch of Beginner Qs - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Bunch of Beginner Qs (/showthread.php?tid=42585) |
Bunch of Beginner Qs - El Forum - 06-11-2011 [eluser]rufisgumbo[/eluser] A bunch of random questions that I've put together while working on my first project. any insight would be much appreciated! Remember Me/Checking Logged in Status I've implemented a basic login system and there is an option to 'remember me'. If that's done a cookie is set. Usually on regular php sites, I would then have an include that just checks at the top of all protected pages - if session set, else if cookie set... Where would I put that in this structure? I have a login controller but it seems like this would need to be part of a library/helper so that I can call it throughout various protected sections? Base URL Rather than constantly call base_url(), is there any benefit to setting it as a global var? if so, where best to set? Session Arrays Can you set a session array var driectly or have to do this ? Code: $search= $this->session->userdata('search'); Escaping Session data Like the input class, does the session class have any type of sanatizing/filtering built-in? How do I bind a value that's used more than once in an sql query Code: AND (first_name LIKE '%?%' OR last_name LIKE '%?%' OR company LIKE '%?%')"; Checking for post values I understood from the user guide that this would return false, if the post input (happens to be radio) was not clicked: Code: if( $find['area'] = $this->input->post('area') ){ But it doesn't it's blank and yet it doesn't return false. Perhaps because it is 'set', but set to blank. Bunch of Beginner Qs - El Forum - 06-11-2011 [eluser]WanWizard[/eluser] Have a look for base classes. Add all stuff you need in multiple classes in the base class, and have your classes (controllers, models) extend those. You don't do global vars. Period. You can only save variables to a session variable. If that's an array, you can't write (or read) the individual elements. I've posted a solution for reading earlier today, it should be easy to extend that to writing as well. Session store is just a variable store, no reason to filter it. If your vars need sanitizing, you will have to do that (I would hate it when a session class would alter my variables). Never used binding, so I can't comment on that. And about your post: if it doesn't return false, what does it return? Do a var_dump() to find out. You can also dump $_POST to see exactly what was posted. |