Welcome Guest, Not a member yet? Register   Sign In
Ci4 useragent
#1

In Ci3 I could use the user agent like this:

Code:
$this->load->library('user_agent');


and then

Code:
$data = array(
'da' => date("Y-m-d H:i:s"),
'AGENT_PLATFORM' => $this->agent->platform(),
'AGENT_BROWSER' => $this->agent->browser(),
'AGENT_VERSION' => $this->agent->version(),
'MOBILE_AGENT' => $this->agent->mobile(),
)


Im trying to replicate the same in CI4 and following the documentation here:

https://codeigniter.com/user_guide/libra...-reference

I dont see how to correlate the CI4.



Ive tried this:

Code:
$agent = $this->request->getUserAgent();
var_dump($agent);
//returns error: Call to a member function getUserAgent() on null
die();
   
var_dump($this->agent);
// returns NULL
die();

var_dump($agent);
// returns Undefined variable $agent
 die();
I feel like i need to be calling the class (as i would with Ci3 using $this->load->library('user_agent'); but there is nothing about it in the docs.
Reply


Messages In This Thread
Ci4 useragent - by CodingInCodeigniter - 10-15-2021, 02:35 AM
RE: Ci4 useragent - by InsiteFX - 10-16-2021, 02:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB