Saturday, June 25, 2016

How to get Client Ip / Browser Name in Laravel?

client ip address


In this session i'm gonna talking how you can detect client IP/ Browser Name. It's better to store client Ip  address in your application as it provides more security for your application as well as User.
So Let's see how you can detect that.

In Laravel it's quite easy to store client Ip. You need to just write below line in controller,

 $user->ip= $request->ip();
Now Let's come to browser side, Sometimes we need to track user browser also. Suppose we need to know from which browser he was last logged in. In this situation we need to keep track of Browser or Device Name also.

For that, we need to install following Package in our application:



after installing the package we can easily can keep track of client Device Name or Browser Name. Write the following line in controller:

$user->device =  BrowserDetect::browserName();

That's it today, Hope you like the tutorial. Thank you!







Related Articles

0 comments:

Post a Comment