Sasha
Sasha

Reputation: 8705

Codeingiter 2.1 - Run function only once, at first load

Is there some way to run function only once, when user load web site? I have a function which, based on the IP of the user, determines country of the user, and I need it to run at the start so that the language of the site is automatically set (via SESSION), and later if there is need, user can change language via button.

Upvotes: 1

Views: 537

Answers (1)

xdotcommer
xdotcommer

Reputation: 48

I think best way is to extend the controller to check if language is set. If it is not set then it runs the geo/language setting function.

Explanation on how to extend controllers http://www.gregaker.net/2011/mar/18/extending-codeigniters-controller/

Upvotes: 2

Related Questions