setcookie to vue app show on the request but not in the app

24 Views Asked by At

I have a front in vue and a back in PHP.

I'm trying to set a cookie but it's not working Chrome recognises the cookie but doesn't save it.

The front is http://192.168.1.17:8080
and the back is http://192.168.1.17

I perform a post like this:

guest
  .post("/user/login", formData, {
  auth: {
    username: process.env.VUE_APP_CLIENT_USERNAME,
    password: process.env.VUE_APP_CLIENT_SECRET,
  },
  headers: {
    "access-control-expose-headers": "Set-Cookie",
  },
})

I set the cookie like this:

header("Access-Control-Allow-Origin: http://192.168.1.17:8080");
header("Access-Control-Allow-Headers: Content-Type, Authorization, Access-Control-Expose-Headers");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Credentials: true");
setcookie('my_cookie', 'cookie_value', time() + 3600, '/', '', false, false);

the result of the request:

netwok tab show the cookie

but here nothing is set:

enter image description here

Sorry if i'm not very clear.

I want to be able to send back the cookie (withCrendtial: true)

I find something similar here but gave me nothing may be missed something: Cookies missing in Chrome dev tools application tab but visible under network section

0

There are 0 best solutions below