Welcome Guest, Not a member yet? Register   Sign In
Best practices/place for setting session data
#1

[eluser]Jonas G[/eluser]
Hi

I am currently setting some session data based on geoip data. In my master view template, the very first line is
Code:
$this->betscout->preflight()

preflight() checks to see whether or not sessions like "country" and "timezone" is already set, and if not, sets them.

What i'm looking for is a better place or better practice to do this. I have been trying to make a pre_controller hook for this, but since this cannot get an instance of ci it doesn't cut it for me.

What is the best practice/place to do this kinda thing?
#2

[eluser]n0xie[/eluser]
Maybe in the construct of MY_Controller?
#3

[eluser]jedd[/eluser]
I echo n0xie's suggestion.

If you head into the [url="/wiki/FAQ"]FAQ[/url] and look at one of the first questions answered there, about repeating lumps of code, you'll see a few suggestions. The [url="/wiki/MY_Controller"]MY_Controller[/url] approach is certainly one of the easiest and most common ways of implementing this kind of functionality. Unsurprisingly, it's in the FAQ because it's asked about so frequently.
#4

[eluser]Jonas G[/eluser]
It works perfectly - thank you!




Theme © iAndrew 2016 - Forum software by © MyBB