login check logic |
[eluser]murichej[/eluser]
hi i'm working on some project where user logins. i need to check if user is logined in all the controllers. it's a little bit silly to copy/paste code for checking session to all controllers. do you suggest any better way for checking if user is logined?
[eluser]rip_pit[/eluser]
sure, look at Extending Core Class @ http://ellislab.com/codeigniter/user-gui...asses.html tutorial here : http://codeigniter.tv/a-10/Extending-the...and-beyond In short MY_controller.php will become the mother of all your other controllers. then it's used to share codes/functions to your other controllers/pages without need of copying/pasting code/functions. It's easy and clean
[eluser]murichej[/eluser]
i have one more question. i created public variable in MY_Controller but i can't access it in controllers extending MY_Controller. any idea? edit: solved. i was using $this->$variable instead of $this->variable
|
Welcome Guest, Not a member yet? Register Sign In |