Does every web request send the browser cookies?

前端 未结 8 1915
太阳男子
太阳男子 2020-12-02 03:38

Does every web request send the browser\'s cookies?

I\'m not talking page views, but a request for an image, .js file, etc.

Update If a w

相关标签:
8条回答
  • 2020-12-02 04:21

    No. Not every request sends the cookies. It depends on the cookie configuration and client-server connection.

    For example, if your cookie's secure option is set to true then it must be transmitted over a secure HTTPS connection. Means when you see that website with HTTP protocol then these cookies won't be sent by browsers as the secure flag is true.

    0 讨论(0)
  • 2020-12-02 04:29

    3 years have passed

    There's another reason why a browser wouldn't send cookies. You can add a crossOrigin attribute to your <script> tag, and the value to "anonymous". This will prevent cookies to be sent to the destination server. 99.9% of the time, your javascripts are static files, and you don't generate that js code based on the request's cookies. If you have 1KB of cookies, and you have 200 resources on your page, then your user is uploading 200KB, and that might take some time on 3G and have zero effect on the result page. Visit HTML attribute: crossorigin for reference.

    0 讨论(0)
提交回复
热议问题