Welcome Guest, Not a member yet? Register   Sign In
Need help reducing database requests to check if a user is logged in
#7

[eluser]zsoerenm[/eluser]
[quote author="BrianDHall" date="1261865396"]However, it IS reasonable to store the variable at the beginning of script execution, so in your logged in function set yourself a variable good only until the script finishes executing. If it is set then you don't run the database call, you just have your logged_in() function return true.

This solves the issue of running the same database call over and over in a loop, as the database is contacted only once the first time logged_in() is called on a particular page.[/quote]

Exactly, this is the way I want it to do! So how do you store your variable? It must be global because codeigniter load->library() method gives a new instance each time it is called. So just saving it in an object attribute wouldn't do the job.
Do you just use global $logged_in? Or stick with any class?


Messages In This Thread
Need help reducing database requests to check if a user is logged in - by El Forum - 12-26-2009, 11:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB