Session Id Is Changing After Every Request

Laravel session ID changes on each request

That means:

  1. Session driver is not starting up properly
  2. Client you're using to connect to laravel app server does not accept cookies
  3. Cookies are set up for wrong domain and/or path.

For case 1 make sure StartSession middleware exists in app/Kernel.php at $middlewareGroups -> web

For case 3 check this answer. In case your app relies on a single domain/path, I recommend you to remove SESSION_DOMAIN.


Finally, manually remove all sessions from your session driver, then run php artisan config:cache and try again.

PHP Session Id changes between pages

According to PHP documentation, session_start must be called before any output is sent back to the browser-- could this page have a rogue CR/LF, Unicode byte-order mark or similar that is causing output before you include('session-inc.php')?

SessionId keeps changing in every curl request in Spring Boot Application

When you use Chrome to send requests to the server: the server uses cookie as session tracking mechanism to identify your session.
When you use CURL: there is no session tracking mechanism, that's why the server creates a new session for every request.

You can read more about session tracking here: https://javapapers.com/servlet/explain-the-methods-used-for-session-tracking/

Express sessionID changes on every client's request

As Mat J. said, fetch does not send cookies for cross-origin by default, so I had to change it:

fetch(getServerAdress() + "/lobby/" + code, {
method: "GET",
credentials: "include",
}

Also I had to enable credentials and origin for CORS on my server:

const cors = require("cors");
app.use(cors({ credentials: true, origin: true }));


Related Topics



Leave a reply



Submit