开发者

Making User Information Available on Every Page

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 yo开发者_如何学编程u).

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.


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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜