problem with basic user authentication - 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: problem with basic user authentication (/showthread.php?tid=13934) |
problem with basic user authentication - El Forum - 12-12-2008 [eluser]bhakti.thakkar[/eluser] hi all, i am trying to create a check on my applications entry point. if the user tries to access the application without login, then he should be redirect() to login page. I am already using sessions in my application and i was shocked to see that if the user doesnt logout and tries to access the index.php, he is directly able to do it. I tried it with hook, but then it will even check my login page and display error message. I also have a function in my application/libraries/site_sentry.php and i also have done this is in my autoload.php $autoload['libraries'] = array('database', 'site_sentry', 'session'); site_sentry.php Code: function is_logged_in() but on my applications mainpage, this doesnt get called. How will i do it. This is my first project with CI Thanks problem with basic user authentication - El Forum - 12-12-2008 [eluser]missionsix[/eluser] including the file is not enough. you need to invoke the class. although i hope you knew this already. site_entry.php Code: class site_entry { I can already see a problem with this though, because every single page is restricted. even the login page, which would go into a redirection loop. problem with basic user authentication - El Forum - 12-12-2008 [eluser]bhakti.thakkar[/eluser] of course the function is_logged_in() is a member of site_sentry class. but the problem is the index.php is not called thru any controller. in my other pages, as the entry point is controller i do as below. there is one page certificate view and it gets invoked from a controller as below class Certificates extends Controller { function __construct() { parent::Controller(); if (!$this->site_sentry->is_logged_in()) {redirect('login');} $this->load->helper('ajax'); } } and automatically the user gets redirected to login. has anybody done anything to get this done??? Thanks in advance problem with basic user authentication - El Forum - 12-19-2008 [eluser]bhakti.thakkar[/eluser] Hi all, i got through this problem. the problem was the sessions weren't ending on the close of browser. i was using the default session library provided by CI which was not enough for my application. So i scanned through different ways for incorporating sessions in CI. there are many OB sessions , native sessions , PHP sessions and many more. you really have to choose between the best suited for your application. i finally opted for Native sessions. now all is fine. hope it helps someone |