浏览器set-cookie的一个小坑
背景:
在浏览器接收到http的response中,如果带有set-
1 |
|
前置:本地设置host
127.0.0.1 a.b.com
执行上述代码
go run main.go
chrome浏览器分别请求:
http://a.b.com:8765/set_cookie_by_no_domain
; HttpResponse Header中Set-Cookie: test_cookie=set_cookie_by_no_domain; Path=/; Max-Age=3600
http://a.b.com:8765/set_cookie_by_domain
HttpResponse Header中Set-Cookie: test_cookie=set_cookie_by_domain; Path=/; Domain=a.b.com; Max-Age=3600
查看cookie
- test_cookie set_cookie_by_domain .a.b.com
- test_cookie set_cookie_by_no_domain a.b.com
发现两个domain是不一致的
请求
http://a.b.com:8765/valid_cookie
,- request Header中:
Cookie: test_cookie=set_cookie_by_no_domain; test_cookie=set_cookie_by_domain
;cookie会传入两个指
- request Header中:
gin读取只会读取一个
浏览器set-cookie的一个小坑
https://berlx.fun/浏览器set-cookie的一个小坑/