• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run function only once, when user enters web site

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.

MY_Controller::__construct() business logic explained in words:

if ( session has no information about language )
check the language based on ip, etc. pp.
save the information in the session

if ( !$this->session->userdata('country') ) $this->yourlibrary->set_ country();

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.