Site wide login - 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: Site wide login (/showthread.php?tid=11639) |
Site wide login - El Forum - 09-17-2008 [eluser]roj[/eluser] 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 Site wide login - El Forum - 09-17-2008 [eluser]Weblizard[/eluser] 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 http://codeigniter.com/wiki/Category:Contributions::Libraries::Authentication/ Site wide login - El Forum - 09-17-2008 [eluser]roj[/eluser] 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. Site wide login - El Forum - 09-17-2008 [eluser]roj[/eluser] This post sums it up well: http://www.antipode.ca/2008/elegant-authentication-in-codeigniter/ (off site, i know, sorry) Site wide login - El Forum - 09-17-2008 [eluser]Bramme[/eluser] I've written a tutorial about this too. edit: just noticed my site is down though. Site wide login - El Forum - 09-17-2008 [eluser]roj[/eluser] More a reference for myself: create your own class: class Initial { function __construct() { $CI =& get_instance(); $CI->load->helper('url'); $CI->load->library('session'); if (($CI->session->userdata('logged') != true) && $CI->uri->segment(1) != 'login') { redirect('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! |