php - How to get browser name in cakephp 3 request? -


i need requesting browsers name in web app.( analytics )

in core php when use $visitor_user_agent=$_server['http_user_agent']it returns mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/43.0.2357.130 safari/537.36 string when using chrome.and preg_match('/chrome/i', $visitor_user_agent) can used know if chrome or not.i not sure if efficient way find browser name or not.

i found get_browser link not giving browser name.

is there way in cakephp3 or core php browser name ?

look documentation of request object.

you can http_user_agent using env() method:

$this->request->env('http_user_agent'); 

you can prepare custom detector:

$this->request->adddetector(     'chrome',     ['env' => 'http_user_agent', 'pattern' => '/chrome/i'] ); 

and in controller use is() method follows:

if($this->request->is('chrome')) {     // stuff chrome } 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -