__construct my bad code with Ion Auth |
Good day
I use authorization with Ion Auth. Registraition work and all good, but my code is so bad. I use it each controller in order to understand whether the user is registered. PHP Code: private $logged_in;
I believe ION Auth comes with a MY_Controller you can add other classes to the MY_Controller and add your code to it a new Controller class.
Just extend the MY_Controller to your new Controller. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I'm sorry. for understanding how it works, I took only some functions in Ion Auth/
I don't see MY_Controller
Ion Auth uses the Auth Controller what I am saying is to create a MY_Controller you can find that in the Users Guide, then create your own Controller and a dd the methods you need to it. You could even place the auth controller in the MY_Controller class.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(07-19-2016, 04:20 PM)Sarog Wrote: I'm sorry. for understanding how it works, I took only some functions in Ion Auth/ use MY_Controller as the base class and extends all your controller from it.the code which is required in all controller goes into MY_controller and you don't have to copy paste in each controller. some common usages: 1)authentication code. 2)loading common libraries , helper or any other resources 3)enable disable profiler or caching 4) simple template system etc google or search on git hub . you will find some good examples.
love codeigniter
Learning best practices Rate my post if you found it helpfull (07-19-2016, 03:56 PM)Sarog Wrote: Good day First of all... that is a really bad code... Why are you calling a CI instance inside the controller? Isn't it already called? Anyway... Besides pointing you to the official documentation which is more than great, I can also refer you to a series about Ion_auth (on my own blog...): http://avenir.ro/authentication-system-w...h-and-ci3/ In there you also have a few more tutorials about working with CodeIgniter. Website: http://avenir.ro
|
Welcome Guest, Not a member yet? Register Sign In |