Documentation ¶
Overview ¶
Package cookie deals with set, get and deleting of HTTP Cookies
Index ¶
- Constants
- type CyclopsCookie
- func (cyclopsCookie CyclopsCookie) Delete(w http.ResponseWriter, cookie *http.Cookie)
- func (cyclopsCookie CyclopsCookie) GetAll(r *http.Request) []*http.Cookie
- func (cyclopsCookie CyclopsCookie) GetCookie(r *http.Request, name string) (*http.Cookie, error)
- func (cyclopsCookie CyclopsCookie) SetCookie(w http.ResponseWriter)
Constants ¶
View Source
const (
// DefaultExpiry is the default expiry for a cookie if a user does not sets it
DefaultExpiry = 3600
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CyclopsCookie ¶
type CyclopsCookie struct { // Name of cookie Name string // Value of cookie Value string // The Domain and Path attributes define the scope of the cookie. They essentially tell the browser what website // the cookie belongs to Path string Domain string // Secure attribute is meant to keep cookie communication limited to encrypted transmission, directing browsers // to use cookies only via secure/encrypted connections Secure bool // HttpOnly attribute directs browsers not to expose cookies through channels other than HTTP (and HTTPS) requests. // This means that the cookie cannot be accessed via client-side scripting languages (notably JavaScript), // and therefore cannot be stolen easily via cross-site scripting HttpOnly bool // SameSite when enabled, a cookie can only be sent in requests originating from the same origin as the target // domain, it helps to prevent XSRF attacks SameSite http.SameSite // Expires specifies time in seconds for a cookie to expire Expires time.Duration MaxAge int }
CyclopsCookie is a struct to hold cookie info
func (CyclopsCookie) Delete ¶ added in v1.1.14
func (cyclopsCookie CyclopsCookie) Delete(w http.ResponseWriter, cookie *http.Cookie)
Delete is used to delete a cookie from the browser by setting the expires attribute to 0
func (CyclopsCookie) GetAll ¶
func (cyclopsCookie CyclopsCookie) GetAll(r *http.Request) []*http.Cookie
GetAll returns array of HTTP cookies
func (CyclopsCookie) GetCookie ¶
GetCookie retrieves a cookie based on the cookie name from request, returns error if cookie does not exist
func (CyclopsCookie) SetCookie ¶
func (cyclopsCookie CyclopsCookie) SetCookie(w http.ResponseWriter)
SetCookie is used to sets a cookie to the responseWriter
Click to show internal directories.
Click to hide internal directories.