-1

I am working on an authentication workflow with Laravel Passport, but the laravel_session cookie changes every time, which is causing issues.

I am not sure how to fix it. And this is what I've tried so far:

In app.php:

$middleware->api([
            \Illuminate\Session\Middleware\StartSession::class,
        ]);

In my .env file:

SESSION_DRIVER=database
SESSION_DOMAIN=site.test
SESSION_SAME_SITE=none
SESSION_SECURE_COOKIE=false
SESSION_LIFETIME=120

Has anyone managed to keep the same cookie in all api requests of a logged-in user?

1
  • 1
    API means stateless session, so there is no cookies like in the stateful sessions. You need to authentifie/distinguish the user/session with a token that you create for the user when he log in / starts his browsing. Commented Jan 28 at 11:53

2 Answers 2

0

maybe what u need is not session but jwt-token?

u can try this tymon/jwt-auth

Sign up to request clarification or add additional context in comments.

Comments

0

If you’re building a stateless API, relying on laravel session cookies isn’t recommended. Instead use API tokens (e.g, Bearer tokens) to authenticate requests.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.