CodeIgniter Forums
tracking user activity via user agent - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: tracking user activity via user agent (/showthread.php?tid=76325)



tracking user activity via user agent - nmaa3003 - 05-03-2020

Hi,

I was thinking of creating a function where i able to record my user's user agent or referrer.

The idea is the moment a user entered the my website no matter from which url/controller. i want to record the user agent/referrer data.

However, is it the only way achieve this is i need to put the this->referrer helper to all my controller method?

Or is there any kind of ''global controller' where it will be applied to all instances?
best approach i think of right now is by using __construct() in all controller. but still, need to applied to all controller rather than 1 for all approach.


RE: tracking user activity via user agent - jreklund - 05-04-2020

Put it in a BaseController and extend it from your other ones, just like you are extending CI_Controller (if on CI3)


RE: tracking user activity via user agent - nmaa3003 - 05-04-2020

(05-04-2020, 03:53 AM)jreklund Wrote: Put it in a BaseController and extend it from your other ones, just like you are extending CI_Controller (if on CI3)
yes.
base controller.
tyvm.