Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

randm's avatar

How to get the user-agent information from the Request object?

Hi, I need to save the agent information in a database after a user logs in.

I grab the ip like this $request->ip();

How can I grab the user-gent data?

0 likes
7 replies
ValsiS's avatar

$request->server('HTTP_USER_AGENT');

use dd($request); to see more

success

Namvari's avatar

@noeldiaz this package isn't updated recently and can use till laravel 8,

any other suggestion?!

DanielRønfeldt's avatar

In Laravel 10.x, the UA can be simply retrieved via the userAgent() method of the Request class, e.g.

$userAgent = $request->userAgent();
8 likes
Snapey's avatar

@DanielRønfeldt Congratulations, you win archaeologist of the day award, answering a 7 year old question.

10 likes

Please or to participate in this conversation.