Answer the question
In order to leave comments, you need to log in
Why is PHP session data not being read when working with AJAX?
Hi all.
The second day I struggle with the problem. The site works on local hosting, but not when transferred to an external server.
During authorization from JS, 2 AJAX requests are sequentially called:
1- Authorization and saving user data in the session.
this piece works, what is needed is saved in the session ...
2. A menu of options available to the user is formed.
But here it doesn't work. A response comes in which the parameter values taken in the session are empty (user id, for example).
At the same time, the session file is alive, there is data in it. Those. in the first case, it was recorded, and in the second, the session was not considered ...
Requests go to the same php file (it is where session_start is located) and then, depending on the key, this or that file with the request and processing is included.
Who can advise what?
Answer the question
In order to leave comments, you need to log in
If requests are called simultaneously, then the session file is locked by the first request and held until the end of the script or until session_write_close().
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question