How to Get User Agent Value in Laravel?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Today now in this post i will show you how to get User Agent Value in laravel. If we are work on laravel application and we need to get the user agent(N.B: user agent mean that user browser details as like firefox, cherome etc) then we can get this very easy. We don’t need to use any $_SERVER variable as like native PHP, but in laravel provide us Request facade. We can fetch this very easily by using following example:

Example

public function ImpressionCount(Request $request)
{
	$impre['useragent'] = $request->server('HTTP_USER_AGENT');
	$input['ip'] = $request->ip();
	print($input);
}

Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →