Documentation ¶
Index ¶
- func DeleteCookie(writer http.ResponseWriter, cookie *http.Cookie)
- func DeleteCookieByName(req *http.Request, writer http.ResponseWriter, name string)
- func GetCookie(req *http.Request, name string) (*http.Cookie, error)
- func GetCookieValue(req *http.Request, name string) (string, error)
- func NewCookie(name, value, path, domain string, maxAge int, secure, httpOnly bool, ...) *http.Cookie
- func SetCookie(writer http.ResponseWriter, cookie *http.Cookie)
- func SetCookieByAttributes(writer http.ResponseWriter, name, value, path, domain string, maxAge int, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteCookie ¶
func DeleteCookie(writer http.ResponseWriter, cookie *http.Cookie)
DeleteCookie
@param cookie 可以为nil
func DeleteCookieByName ¶
func DeleteCookieByName(req *http.Request, writer http.ResponseWriter, name string)
DeleteCookieByName
@param name 可以为"",但无意义
func GetCookie ¶
GetCookie
!!!: (1) 获取到的 *http.Cookie 实例,如果对其进行了修改,浏览器端并不会同步修改(除非修改后set回去). (2) 如果不存在与传参name对应的cookie,将返回 (nil, http.ErrNoCookie). (3) 如果返回error,唯一的原因:不存在与 传参name 对应的cookie.
@param req e.g. gin.Context Request @param name 可以为"",但无意义
func NewCookie ¶
func NewCookie(name, value, path, domain string, maxAge int, secure, httpOnly bool, sameSite http.SameSite) *http.Cookie
NewCookie
@param name 可以为"",但无意义,设置不了 @param value @param path 可以为"" @param domain 可以为"" @param maxAge 单位为秒(s) @param secure @param httpOnly @param sameSite e.g. http.SameSiteDefaultMode
func SetCookie ¶
func SetCookie(writer http.ResponseWriter, cookie *http.Cookie)
SetCookie
@param writer e.g. gin.Context Writer @param cookie 可以为nil,但这样的话调用此方法就没意义了
func SetCookieByAttributes ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.