cookieKit

package
v2.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

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

func GetCookie(req *http.Request, name string) (*http.Cookie, error)

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 GetCookieValue

func GetCookieValue(req *http.Request, name string) (string, error)

GetCookieValue

@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

func SetCookieByAttributes(writer http.ResponseWriter, name, value, path, domain string, maxAge int, secure, httpOnly bool, sameSite http.SameSite)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL