Welcome Guest, Not a member yet? Register   Sign In
Site wide login

Hi all,

I apologise in advance, I'm fairly new to codeigniter and haven't learnt all the little hooks and that just yet, so sorry if this fairly routine.

I often have to develop sites which are closed where content is only available to authenticated users. I previously have written scripts to use session keys and then load user information on every page load (which is required for the applications to run properly). I was wondering if there is an easy way to implement this through codeigniter? The obvious choice is to load a hook before the controllers to see if a user is authenticated and if so load the correct info but I can't quite get this to interact with the session class.

I'm probably missing something extremely trivial, but like I said...new to this!

thanks, in advance

Ci does not come with authentication library it self , you can write your own library or use 3rd party libraries
check wiki for more info

Yeah, sorry, should have said that. Most of the ones I've looked at work on the more traditional front-end — back-end website while I'm needing to build a purely back-end site with all controllers (bar any login script) requiring authenticated user information.

This post sums it up well:


(off site, i know, sorry)

I've written a tutorial about this too.

edit: just noticed my site is down though.

More a reference for myself:

create your own class:

class Initial
function __construct()
$CI =& get_instance();

if (($CI->session->userdata('logged') != true) && $CI->uri->segment(1) != 'login')

and save it as Initial, then autoload it with the other autoload classes in autoload.php.

My problem was in the naming convention - I didn't realise that your own classes had to stick to PHPs capitalised filenames....

Anyway, thanks for the help!

Theme © iAndrew 2016 - Forum software by © MyBB