postman-chrome-interceptor icon indicating copy to clipboard operation
postman-chrome-interceptor copied to clipboard

Interceptor multiplies & mixes cookies

Open moeskerv opened this issue 10 years ago • 2 comments

Postman, Interceptor and Jetpacks is used to test a REST API.

I use the Cookie header in Postman request to send a cookie together with the request. The value field for the cookie is filled with environment variables from Postman like this

User 1

Header Value
Content-Type application/json
Authorization Basic {{auth}}
Cookie GSESS={{cookie}}_{{id}}

This works fine for a while, the cookie is sent:

image

But after some calls interceptor starts to send multiple identical cookies.

image

When different users are involved with different cookie content it also happens that cookies gets mixed:

User 2

Header Value
Content-Type application/json
Authorization Basic {{auth2}}
Cookie GSESS={{cookie2}}_{{id2}}

image

As a workaround deleting the browser cookies helps for the next few requests. Unfortunately this issue is easy and often reproduced in my scenario. My collections work fine with newman.

moeskerv avatar Oct 15 '15 13:10 moeskerv

Some more background which may help:

Sending multiple cookies:

IMHO this seems to be an Chrome issue, I can see that in the setCookiesFromHeader the interceptor sets the correct cookie and it sets it once only as expected. In my tests I'm using quite long URLs (long path), this seems to be the background, chrome seems to mix them for some reason. When reduce the url by excluding the path in the setCookiesFromHeader no double cookies are sent any more.

Mixing cookies, or sending wrong cookie

This seems to be caused by the async. nature of the chrome.cookies.set function used in setCookiesFromHeader. Due to interceptor does not wait for the callback it seems to happens that the correct cookie sometimes isn't yet set when the XHR call is made. Observation: When stepping through the code the issue does not occur. When adding a dirty wait in the code after chrome.cookies.set the issue does not occur.

moeskerv avatar Oct 21 '15 10:10 moeskerv

@moeskerv Thanks for reporting this. We'll investigate and get back to you soon.

abhijitkane avatar Oct 21 '15 11:10 abhijitkane