gofiber / fiber

⚡️ Express inspired web framework written in Go
https://gofiber.io
MIT License
33.9k stars 1.67k forks source link

🚀 [Feature]: ctx.Cookie is missing "Priority" Option #2515

Closed the-hotmann closed 1 year ago

the-hotmann commented 1 year ago

Feature Description

I am refering to Chromes (~65% browser market share) cookie setting Priority (LINK, docs) which tells the browser which cookies are more important than others, for example login cookies and creates a priority of which cookies can be deleted first if the browser needs to.

I am currently missing this option in the docs and also could not add it in code - so I assume this is not implemented.

AFAIK this is a chromium only thing by now, so other browsers wil just ignore it - no downsides/sideeffects.

Additional Context (optional)

No response

Code Snippet (optional)

// Set the token as a cookie
c.Cookie(&fiber.Cookie{
    Name:     "Cookie Name",
    Value:    "Cookie value",
    Path:     "/",
    Expires:  time.Now().UTC().Add(900 * time.Second),
    Secure:   true,
    HTTPOnly: true,
    SameSite: "Strict",
    //Priority: "High",
})

Options for Priority are: Low, Medium & High

Checklist:

ReneWerner87 commented 1 year ago

does not seem to be currently supported by our core

https://github.com/valyala/fasthttp/blob/ffdf59d04ca2f02556308d60d37b8e77ea04484c/cookie.go#L67-L97

as soon as this happens we can include it

to speed this up, you can also create a report at fasthttp

the-hotmann commented 1 year ago

Thanks for the quick reply, I appreciate it!

Will link them: https://github.com/valyala/fasthttp/issues/1580

leonklingele commented 1 year ago

I‘ve never heard of the Priority directive, and also MDN doesn’t list it: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie Are you sure it’s still supported?

ReneWerner87 commented 1 year ago

had also looked there, am also not sure

ReneWerner87 commented 1 year ago

https://github.com/valyala/fasthttp/issues/1580#issuecomment-1603908117 erik means its deprecated so better to not support it

ReneWerner87 commented 1 year ago

https://datatracker.ietf.org/doc/html/rfc6265#section-5.2

image

since it is not part of the standard and is also marked as deprecated, we will not support this

the-hotmann commented 1 year ago

I understand, it is not officially supported. But would not hurt/break anything. Anyway I understand. Should have thecheck the IEFT before.

Thanks anyway!