Saturday, 19 January 2019

Cookies disappear after redirect

I have:

1) A client side app that has its own domain: http://client.com

2) A server side app that has a separate domain: http://server.com

Now,

the scenario is:

1) Opening http://client.com/home in the browser, which displays an HTML page.

2) http://client.com/home makes an AJAX request to http://server.com/login (CORS enabled)

3) http://server.com/login stores a cookie 'auth' and sends a redirect instruction to http://client.com/welcome

Response:

Set-Cookie: auth=1479da80-197c-11e9-ba74-59606594e2fb; Path=/

4) The browser receives the response, which does contain the cookie 'auth'

5) The browser redirects itself to http://client.com/welcome

6) 'auth' cookie is sent to http://client.com/welcome

Request:

Cookie: auth=1479da80-197c-11e9-ba74-59606594e2fb

7) http://client.com/welcome returns HTML but does not return the cookie 'auth'

enter image description here

enter image description here

8) http://client.com/welcome makes an AJAX request to http://server.com/data (CORS enabled), but the cookie 'auth' is not sent

9) http://server.com/data doesn't recognize the user because there is no cookie

The client side is an angular app hosted by Node.js



from Cookies disappear after redirect

No comments:

Post a Comment