Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cookie): allow Max-Age to be greater than 30 days #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shooma
Copy link

@shooma shooma commented Mar 17, 2021

See: gorilla/sessions#48 (comment)

Now I got [sessions] ERROR! securecookie: expired timestamp after 30 days even if I set store options for a f.e. century

  store := cookie.NewStore([]byte(secret))
  store.Options(gs.Options{
    Path:     "/",
    MaxAge:   60 * 60 * 24 * 365 * 100, // 100 years
    HttpOnly: true,
  })

or if I set MaxAge on cookie itself

session.Set("userID", "user id")
session.Options(sessions.Options{
    MaxAge: 60 * 60 * 24 * 265 * 100,  // 100 years
})
_ = session.Save()

I found same issue on gorilla/sessions, and solution was to explicitly call function MaxAge(int) on CookieStore. But in gin-contrib/sessions this CookieStore struct is hidden under local store:

type store struct {
  *gsessions.CookieStore
}

So I have no way to fix problem on application side.

And I hope this fix will save several hours for someone else.

@shooma
Copy link
Author

shooma commented Mar 17, 2021

This solution works only for store.Options (on session storage init) but not work for session.Options (on session init)

@shooma
Copy link
Author

shooma commented Sep 10, 2021

Hi guys, is someone alive here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant