PHP session lost after AJAX reload

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • PHP session lost after AJAX reload

    Hi everyone,

    I’m running into a strange issue with PHP sessions in my project. I have a login system that works fine on normal page loads, but when I make an AJAX request (using fetch), the session data seems to disappear or reset.

    For example, after logging in, $_SESSION['user_id'] is correctly set. However, when I call a PHP script via AJAX, $_SESSION is empty, even though session_start() is included at the top of every file.

    I’ve already checked:
    • Session is started on every request
    • Cookies are enabled in the browser
    • Same domain and no redirects

    Could this be related to headers, CORS, or how fetch handles cookies? Do I need to explicitly include credentials in the request?

    Any help or explanation would be really appreciated!
Lädt...
X