This commit is contained in:
Gerasimos (Makis) Maropoulos 2022-04-02 20:45:47 +03:00
parent 872dd45359
commit c5139b22ee
No known key found for this signature in database
GPG Key ID: 66FCC29BD385FCA6
2 changed files with 14 additions and 1 deletions

View File

@ -41,6 +41,15 @@ func withCookieOptions(ctx iris.Context) {
// * CookieExpires // * CookieExpires
// * CookieEncoding // * CookieEncoding
ctx.AddCookieOptions(iris.CookieAllowReclaim()) ctx.AddCookieOptions(iris.CookieAllowReclaim())
// ctx.AddCookieOptions(iris.CookieSecure)
// OR for a specific cookie:
// ctx.SetCookieKV("cookie_name", "cookie_value", iris.CookieScure)
// OR by passing a a &http.Cookie:
// ctx.SetCookie(&http.Cookie{
// Name: "cookie_name",
// Value: "cookie_value",
// Secure: true,
// })
ctx.Next() ctx.Next()
} }

View File

@ -38,7 +38,11 @@ func logout(ctx iris.Context) {
func main() { func main() {
app := iris.New() app := iris.New()
sess := sessions.New(sessions.Config{Cookie: cookieNameForSessionID, AllowReclaim: true}) sess := sessions.New(sessions.Config{
Cookie: cookieNameForSessionID,
// CookieSecureTLS: true,
AllowReclaim: true,
})
app.Use(sess.Handler()) app.Use(sess.Handler())
// ^ or comment this line and use sess.Start(ctx) inside your handlers // ^ or comment this line and use sess.Start(ctx) inside your handlers
// instead of sessions.Get(ctx). // instead of sessions.Get(ctx).