【发布时间】:2022-01-14 19:56:08
【问题描述】:
Cookie struct 中的 Expires 和 Max-Age 有什么区别? 看不懂。
type Cookie struct {
Name string
Value string
Path string // optional
Domain string // optional
Expires time.Time // optional
RawExpires string // for reading cookies only
// MaxAge=0 means no 'Max-Age' attribute specified.
// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
// MaxAge>0 means Max-Age attribute present and given in seconds
MaxAge int
Secure bool
HttpOnly bool
SameSite SameSite
Raw string
Unparsed []string // Raw text of unparsed attribute-value pairs
}
【问题讨论】:
-
使用 MaxAge 并阅读 RFC
标签: http go cookies expires-header max-age