I'm building a laravel application where I want to keep track of client browser details such as browser name. How do I do it using Laravel ?
public function postUser(Request $request)
{
$user = new User();
$user->name = $request->Input(['name']);
$device= $request->header('User-Agent');
dd($device);
$user->save();
return redirect('userSavePage');
}
I have used this $device= $request->header('User-Agent');
But while I dd() the output I get something Like this:
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"
How do I get actual browser details?
You can also find out the browser version by passing the result of Agent::browser() to the version() method like so: 1$browser = Agent::browser(); 2$version = Agent::version($browser);
Route::get('browser', function () { //create new agent instance $agent = new Jenssegers\Agent\Agent(); //check if agent is robot if ($agent->isRobot()) { return $agent->robot(); } //if agent is not robot then get agent browser and platform like Chrome in Linux $agent = $agent->browser() . " in " .
This is a Laravel package that utilizes the Mobile Detect PHP Class under the hood: Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
To get the MAC address, pass the parameter 'getmac' which returns the MAC address of the client. 'getmac' is a CMD command to get the MAC address. To get the MAC address, we use exec() function. $macAddr = exec('getmac');
I ended using the faster, and simpler way:
$request->header('User-Agent');
Hope it helps someone!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With