Home  >  Q&A  >  body text

Why does the number of cookies in the "Cookie" request header exceed the number of cookies set in the "set-cookie" response header?

I am a newbie to web crawling, so my understanding of http requests is very shallow. When I inspect certain requests I send to a website, such as add to cart, the dev tools show that there are more values ​​ in the "Cookie" header of the request, which are set by "set -cookie" response header is set.

How does this work?

More specifically, one cookie in the "set-cookie" header of the response will contain the cart id, but when looking at all cookie values ​​in the request header, there will also be a cart id in the "Cookie" header , but there are other cookies such as "checkout session lookup" and "checkout session token".

However, these cookies are not set in the "set-cookie" header of the response, so how do they get there?

Suppose I want to grab the complete "Cookie" value of all cookies included in the request header, not just those cookies in the response header. Is there a way to do this?

Thank you for your help!

P粉244155277P粉244155277195 days ago3715

reply all(1)I'll reply

  • P粉667649253

    P粉6676492532024-04-06 10:58:23

    I think this may be related to the JavaScript on this page. For example, the following code sets a new cookie: document.cookie="username=John Doe";

    Therefore, cookies can not only be sent through request headers.

    To get the full cookie, I think you might need a headless browser.

    reply
    0
  • Cancelreply