setcookiehttpcookie

Browser is not saving cookies


I am calling API at https://engine-beta.mydomain.com/list* inside http://localhost.mydomain.com website, API response with set-cookie: with domain landing.vahanacloud.com. The browser is ignoring(not saving) this cookie.

But with the same scenario, in API response with set-cookie: with domain .maydomain.com is working fine.


Solution

  • It is because you host domain and you domain is different.

    Host Domain: Where the api is deployed. App Domain: Where you web app is running.

    If you save cookie to parent domain, all the sub domain will have access to cookies but siblings domain will not have access to other sibling cookies.