0

enter image description here

enter image description here

enter image description here

enter image description here

AS see my captures, i made jwt login page. it makes jwt token but after that, go home and check user's name but Auth::user() is null

if i dd($user) on api/auth/login page, user's info appears but go home page and trying to check user's info, there is only null page

here is my full code. https://github.com/sksmsWKd/MetaComposerProto

would you do me a favor?

this is my login function on AuthController. it makes jwt token well but can't maintain user's login to other page...

  $input = $request->only('email', 'password');
        $jwt_token = null;

        if (!$jwt_token = JWTAuth::attempt($input)) {
            return response()->json([
                'success' => false,
                'message' => 'Invalid Email or Password',
            ], Response::HTTP_UNAUTHORIZED);
        }


     
        return response()->json([
            'success' => true,
            'token' => $jwt_token,
        ]);
sksmsWKd
  • 155
  • 2
  • 12
  • JWT is a stateless session solution. there is no "to the other page" session resolution by cookies. You need to specifically send the JWT in the header of each request that requires authentification. like in ajax calls or api consumption from other tools like postman or wget or curl... – N69S Jan 22 '22 at 10:05
  • @N69S thanks a lot. i will find how to send JWT token to other page on laravel. – sksmsWKd Jan 22 '22 at 10:18
  • @N69S can i ask you if https://stackoverflow.com/questions/49432567/laravel-jwt-multi-page-structure this site will be helpful to me? – sksmsWKd Jan 22 '22 at 10:19
  • Notice that in that question they are using vue.js (any js framework will do) to handle the front end and they use laravel as an API exclusively. – N69S Jan 22 '22 at 10:26
  • @N69S thanks a lot. can i ask one more thing?? i'm making front with blade.php , should i add adding header tag? props? to every front pages? – sksmsWKd Jan 22 '22 at 11:53

0 Answers0