J
J
Jedi2020-02-27 03:17:14
Laravel
Jedi, 2020-02-27 03:17:14

How to send an AJAX request to an already authorized one?

Sending files using ajax. I want to get the object of the user who sent the request. How can I send a request so that Laravel understands that the client is authorized and get the user object?

There doesn't seem to be anything in the documentation about this.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin B., 2020-05-20
@PHPjedi

Do you know why?
Because I didn't read the documentation. If I read it, I would know that if you send a request to a route that is in api.php, then there will be no session in them. Since they are used for APIs, not web sites.
To make it all work, you need to move these routes from api.php to web.php
or use token authorization

A
Andrey Suha, 2020-02-27
@andreysuha

Auth::user() ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question