3

I want to get exact info of which os user is login for this I am using codeigniter useragent library

$this->load->library('user_agent');
echo $this->agent->platform(); die;

but it shows me Unknown Windows OS when I login using window is there any other way to get exact operating system

  • 2
    http://stackoverflow.com/questions/18070154/get-operating-system-info-with-php – Chetan Ameta Mar 31 '16 at 06:42
  • 1
    Client environment detection is not reliable and often leads to false assumptions or missing information. This is due to the fact that it is based on insecure information. Insecure because it is under the sole control of the client, so can be filtered or manipulated at will. – arkascha Mar 31 '16 at 06:44

3 Answers3

2

Pleas try using this function,

echo php_uname();
echo PHP_OS;

since codeigniter is written in php, this will work, you can also refer to the php doc here http://php.net/manual/en/function.php-uname.php

Hope this will help

Fil
  • 8,225
  • 14
  • 59
  • 85
0

You can use $_SERVER['HTTP_USER_AGENT'] to get client agent in PHP, User_Agent is one information in HTTP REQUEST HEAD so every client accessing your server will send this information to your server, but it not reliable and can be faked.

Kevin Yan
  • 1,236
  • 11
  • 19
0

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

if ($this->agent->is_browser()){

$agent = $this->agent->browser().' '.$this->agent->version();

} elseif ($this->agent->is_robot()){

$agent = $this->agent->robot();

} elseif ($this->agent->is_mobile()){

$agent = $this->agent->mobile();

} else{

$agent = 'Unidentified User Agent';

}

echo $agent;

echo $this->agent->platform();

Silent Psycho
  • 21
  • 1
  • 3
  • While this code block may answer the question, it would be best if you could provide a little explanation for why it does so. Also, see [Formatting Help](https://stackoverflow.com/help/formatting). – nik7 Apr 22 '21 at 08:37