Welcome Guest, Not a member yet? Register   Sign In
login check logic
#1

[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?
#2

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

[eluser]murichej[/eluser]
that's great, thanks!
#4

[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 Big Grin
#5

[eluser]rip_pit[/eluser]
glad that it helped !




Theme © iAndrew 2016 - Forum software by © MyBB