ctx.Request()
returns a net/http#Request
.Context
provides some helpers to make the most common use cases of cookies easier accessible to you and without any custom additional code of yours that would be required if you just using the Request's Cookies methods.SetCookie
and UpsertCookie
methods add or set (replaces if necessary) a cookie.CookieOption
can be used to modify the "cookie". You'll see later on what the available options are, custom ones can be added depending on your web application requirements, this also helps to not repeat yourself in a codebase.Context
has a SetSameSite(http.SameSite)
method too. It sets the "SameSite" cookie field for all cookies to be sent.SetCookieKV
method which does not require an import of the net/http
package.SetCookieKV
is 365 days. You can either use the CookieExpires
Cookie Option(see below) or globally by setting the kataras/iris/Context.SetCookieKVExpiration
package-level variable.CookieOption
is just a type for func(*iris.Cookie)
.HttpOnly field defaults to true forRemoveCookie
andSetCookieKV
.
CookieEncoder
and sets the cookie's value to the encoded value.SetCookie
and SetCookieKV
.CookieDecoder
and sets the cookie's value to the decoded value before return by the GetCookie
.GetCookie
.CookieEncoder
can be described as:CookieDecoder
:GetCookie
returns cookie's value by its name, returns empty string if nothing was found.ctx.Request().Cookies()
method returns a slice of all the available request cookies. Sometimes you want to modify them or perform an action on each one of them, the easiet way to do that is by the VisitAllCookies
method.RemoveCookie
method deletes a cookie by its name and path = "/", the root one.iris.CookieCleanPath
Cookie Options, as : RemoveCookie("nname", iris.CookieCleanPath)
.HttpOnly
to true. It performs a removal of cookie based on the web standards.