Introduction to SameSite

Reference Documents

https://web.dev/samesite-cookies-explained/

https://web.dev/samesite-cookie-recipes/

https://web.dev/schemeful-samesite/

Beginning with Chrome89, different protocols are also considered cross-site requests

https://www.chromestatus.com/feature/5096179480133632

How to Set?

  1. func main() {
  2. s := g.Server()
  3. s.BindHandler("/", func(r *ghttp.Request) {
  4. r.Cookie.SetHttpCookie(&http.Cookie{
  5. Name: "test",
  6. Value: "1234",
  7. Secure: true,
  8. SameSite: http.SameSiteNoneMode,// Custom SameSite, used together with secure
  9. })
  10. })
  11. s.SetAddr("127.0.0.1:8080")
  12. s.Run()
  13. }