Answer the question
In order to leave comments, you need to log in
How to transfer cookies from a subdomain to php?
There is a web application on the example.com
domain
There is a PHP REST API on the api.example.com
domain
When POSTing a request from example.com to api.example.com/signin
api.example.com/signin returns a set-cookie token, but for some reason then it does not save it in the browser and, accordingly, does not send
it with
subsequent requests .
if (isset($_COOKIE['token'])) {
.....
} else {
......
setcookie("token", $new_token, $expr_time,' /', '.example.com', false, false);
}
Answer the question
In order to leave comments, you need to log in
Solved the problem by adding withCredentials: true to the headers of each request on the side of the web application.
with axios looks like this
axios.post(API_SERVER + '/login', { email, password }, { withCredentials: true })
axios.get(API_SERVER + '/todos', { withCredentials: true })
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question