views:

45

answers:

1

I'm an amateur, admittedly so, but I'm having fun trying to learn a little more about programming, and php in general, using CodeIgniter.

I have a test site up and running and feel like I have a decent grasp of MVC. Without any formal background though, I know my architecture is screwy and sloppy so I poll from time to time for best practices from those in the know (that's you).

There's some data about users that I'd like to have access to on every page. Said data is stored in 3 different db tables. The only way I can think to get the information into every controller is to create a model that pulls this data and then call the model in every controller, passing the data onto the view.

Another idea would be to create a library that loads the model, autoload it, and then grab the specific data from the functions in the library when I need them.

Am I thinking about this correclty?

Thanks.

+1  A: 

You can use sessions.

When a user login, store his/her basic information in session by getting it from databases. Now you can directly get them from session and show them on any webpage. Make shure this information does not contain user password :)

NAVEED
I woke up this morning and one of the first things that popped into my head was, "hey dummy. Use sessions." I need to learn to refrain from asking questions when I'm tired. Sorry for wasting the time of everyone who read this. Thanks, @naveed for the answer.
Ryan