Comments

  1. says

    Hi!

    Thanks for a brief tutorial/info about a logical way to secure different parts of the site with ionAuth.

    I AM looking forward to the next post on Datamapper with ionAuth as i am doing the same thing soon !

    • says

      Sorry guys, I don’t think I’m going to get around to the next article. I’ve moved on to developing in Laravel, as CodeIgniter is a dying framework. Keep using it if you need to maintain a legacy application, but I wouldn’t start any new projects in CodeIgniter.

  2. Isht.Ae says

    Hi Kyle,

    I’ve follow your tutorial, but i get only blank page.

    Is there something wrong?

    Thx for the answer.

    • Orlando says

      Bro dont waste your time with this, i’ve given this crap 2 days of my life.. i’m going to try and build my own, i suggest you try and do the same… best of luck

    • says

      The most common cause of the “white screen of death” in CodeIgniter is extra whitespace in one of your source files, or a fatal programming error that wasn’t caught. Put some < ?php echo "Break point 1"; exit; ?> lines in your source until you narrow down the point at which your app fails.

        • ttt says

          I’ve changed Secure_Controller for CI_Controller and i looked at the “Break point” lines…
          That´silly but’s the tip of the iceberg…
          i’ll keep looking.

          • says

            Well, using the “silly break point” method you should now have a pretty good guess as to which part of your code is crashing. If you want to paste the code between the last “break point” that worked and the next one that didn’t I’ll try to help you debug.

            Double check for missing semicolons, braces, etc.

  3. ttt says

    Oh, Kely, I didnt mean that “break point” was silly… “the change i made” was the silly part/thing.
    I continued looking at the code, and i looked for an error… it says this:

    A PHP Error was encountered

    Severity: Notice

    Message: Undefined property: App_main::$ion_auth

    Filename: core/Secure_Controller.php

    Line Number: 14

    Fatal error: Call to a member function logged_in() on a non-object in C:\xampp\htdocs\final\application\core\Secure_Controller.php on line 14

    —————-
    controller/app_main.php:

    load->view(‘header’);
    $this->load->view(‘message’);
    echo “Break point 2″; exit;
    $this->load->view(‘footer’);

    }

    }

    ?>

    ——————

    core/Secure_Controller.php:

    ion_auth->logged_in())
    {
    redirect(base_url() . ‘auth/login’);
    }
    }

    }

    ?>

    • says

      I think you’re missing the keyword this. Unless you’ve assigned the the Ion Auth library to the $ion_auth variable in your controller, you should always refer to it as $this->ion_auth

  4. ttt says

    It’s working fine!!!
    solution:

    Add to config/autoload.php

    $autoload[‘libraries’] = array(‘Ion_auth’);

  5. wan says

    “Stay tuned for my next post on how to integrate Ion Auth with WanWizard’s DataMapper ORM.”

    so this tutorial already available? I really need to learn how to use both

    • says

      Sorry, I don’t think I’m going to get around to the next article. I’ve moved on to developing in Laravel, as CodeIgniter is a dying framework. Keep using it if you need to maintain a legacy application, but I wouldn’t start any new projects in CodeIgniter.

  6. gailsedotes says

    finally something that actually works out of the box and explains why.

    it’s always in the last place you look!

    • says

      Sorry, I don’t think I’m going to get around to the next article. I’ve moved on to developing in Laravel, as CodeIgniter is a dying framework. Keep using it if you need to maintain a legacy application, but I wouldn’t start any new projects in CodeIgniter.

  7. Nik says

    Hello,

    I’m new to a lot of this stuff, but do have a programming background. I’ve setup Ion Auth as per all the installation instructions, but I get this error:

    Fatal error: Call to undefined function lang() in /application/views/auth/login.php on line 1

    Any ideas as to what I’m doing wrong or missed?

    Many thanks in advance!

    NB.

  8. says

    Well I got this working but the issue I run into now is that when I use the auth controller and extend the Secure_controller then try to go to the login page it redirect breaks since theres no check to see if its on the login page.

    Just curious if you had a fix for this? Could add some simple checks on the url to ignore on certain pages.

    • says

      Only pages that require a successful login to be viewed should extend Secure_Controller, so in your case, the Auth controller would not extend Secure_Controller.

      I usually build a Public_Controller that all of my public facing controllers extend, and a Secure_Controller that all my pages requiring a login extend.

      You could add checked to the Secure_Controller to ignore certain urls, but its much easier to simply not allow your Auth and other public facing controllers to extend Secure_Controller in the first place.

  9. says

    Thanks a ton for utilizing some time to write “Best CodeIgniter Ion Auth Tutorial | Kyle Noland |
    Dallas Website Design and Development”. Thank you yet again ,Patricia

  10. Girish SH says

    Hi Kyle,

    I am new to Ion-auth

    I applied it to my project, But one thing I am not getting
    That is after logging out also the back button of browser will be active,
    If I press that previous page will be displayed.
    I have to make my application stronger. It should not redirect to previous page.

    How to do it?

    Thanks and Regards,
    Girish

    • says

      This is simply how browsers and the internet work. You are able to use the Back button because the previous page you were on was cached by your browser. If you use the back button, then try to use one of the links on the page access some other secure area of your app, if you’ve implemented this login system I’ve written about correctly, you will be redirected back to the login page because you are no longer authenticated.

  11. john says

    you dont seem to actually load the ion_Auth library anywhere ?
    $this->load->library(‘ion_auth’);

    and also how do i redirect my logged in user anywhere ?

    • says

      The Ion Auth library is autoloaded. You can manually load your library if you want, but for a library that will be called on ever page load to determine if the user is logged in, I prefer to autoload and save a couple lines of code.

      In this example, redirection is handled by the constructor in the Secure_Controller. You can redirect your users anywhere they need to go, but you’ll probably want to do that right after the check for authentication happens.

    • says

      It is isn’t strictly required, but I prefer to autoload libraries that end up being used on nearly every page load. It saves a little repetitive code in my Controller classes.

Leave a Reply to ttt Cancel reply

Your email address will not be published. Required fields are marked *