• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Site wide login

#1
[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

#2
[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:Con...ntication/

#3
[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.

#4
[eluser]roj[/eluser]
This post sums it up well:

http://www.antipode.ca/2008/elegant-auth...deigniter/

(off site, i know, sorry)

#5
[eluser]Bramme[/eluser]
I've written a tutorial about this too.


edit: just noticed my site is down though.

#6
[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!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.