Discrepancy in cookies between BrowserContext and browser developer tools

Description
When using the k6 browser module to automate login flows, I’m observing inconsistent cookie data between:

  1. Cookies visible in browser developer tools (Application > Cookies)
  2. Cookies retrieved via BrowserContext.cookies()

The differences include missing cookies, mismatched expiration times, and inconsistent domain/path settings.


cookie value is eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6IjAxOTUzYzY0LTZlODgtNzAwMC04NTJkLWUxMmJlODNiZjVjNyIsImlhdCI6MTc0MDQ3NDk2OSwiZXhwIjoxNzQ4MjUwOTY5LCJhdWQiOiJhY2NvdW50IiwiaXNzIjoidGVybSBzdHJ1Y3R1cmUgaW5zdGl0dXRlIn0.9nVktI-yFaA_rHWzoBiTVmmXXf2rQ5bw-5CgWkECbys


let cookies = await context.cookies(); console.log(cookies);
value is eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJub25jZSI6IjAxOTUzYzY0LTY0NDAtNzAwMC04NTJkLWQyNDdmYmM0Mjc0ZSIsImlhdCI6MTc0MDQ3NDk2NywiZXhwIjoxNzQwNDc1ODY3LCJhdWQiOiJhY2NvdW50IiwiaXNzIjoidGVybSBzdHJ1Y3R1cmUgaW5zdGl0dXRlIn0.YHqozNqFkI7tD5eVrjYpleOBcIfw7cys9Wg2C41dfMg

I copied the cookies from the browser and used them to make API requests to the system, which worked successfully. However, when using the cookies retrieved from context, the requests failed authentication.

I don’t understand why this discrepancy occurs.