L
L
lexstile2021-12-13 13:02:02
PHP
lexstile, 2021-12-13 13:02:02

How to set cookie with php when working with rest api?

There is an endpoint for the POST method, in it I try to execute:

setcookie('token', '111111', $exp, '/', 'localhost');

Network -> Cookies :
61b71999ec36b849784126.png

But Application -> Cookies is empty.
On subsequent requests , $_COOKIE is also empty.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2021-12-13
@lexstile

You need to set "withCredentials" in the client

const app = axios.create({
    baseURL,
    withCredentials: true
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question