PHP session variables not preserved with ajax

前端 未结 6 1096
臣服心动
臣服心动 2020-12-03 17:36

I have a one page website that uses AJAX to load new php files and update the display.

I start my php session on the main page but when I use ajax to update inner ht

6条回答
  •  既然无缘
    2020-12-03 18:02

    You're trying to use existing session data from your application in an ajax call. To do that, change how you're calling session_start like so:

    // With ajax calls
    if (session_status()==1) {
        session_start(); 
    }
    

    When making ajax calls to php scripts that need existing session data, use session_start after session_status.

    http://php.net/session_status

提交回复
热议问题