Welcome Guest, Not a member yet? Register   Sign In
Using Classes in Helper files?

I'm using CI's database class in my controllers. I have a "is_logged_in" function that I will have to use in every controller/view so I created my own helper file because I don't want to have to copy and paste it over and over again. I check the session footprint against the footprint I put into my database. However, now I have no way of getting to the database or the session data because I can't use the class functions inside a regular function. Ideas? Or am I just missing something?

Just use model.

Create a function in a model. Check session or do whatever you want. like redirecting to login form if not logged and so on...

Now access this function in controller functions.

I like this way..You can decide your own.

You know what? I was wondering if that's what models were for. I've only been using CI for about 2 weeks. I've found MVC to be quite useful. However I've only gotten to play with the V's and C's so far...lol. Thanks!

Models are very easy to use.Just do one thing read user guide carefully then you will ask less Qs and code more.

Theme © iAndrew 2016 - Forum software by © MyBB