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

Add cookie store Maxage sample to avoid possible misleading. #30

Closed
raven-chen opened this issue May 15, 2019 · 2 comments
Closed

Add cookie store Maxage sample to avoid possible misleading. #30

raven-chen opened this issue May 15, 2019 · 2 comments

Comments

@raven-chen
Copy link

raven-chen commented May 15, 2019

Propose adding cstore.Options.MaxAge(xxx) to the sample.

In the sample, it says

	sessionStore = abclientstate.NewSessionStorer(sessionCookieName, sessionStoreKey, nil)
	cstore := sessionStore.Store.(*sessions.CookieStore)
	cstore.Options.HttpOnly = false
	cstore.Options.Secure = false

So we wrote cstore.Options.Maxage = 2654000 in the project. but keep getting 500 error because of the cookie is expired. (btw return 500 on cookie expiry is too much?). then we found the session store's MaxAge is the value we set but the MaxAge in securecookie still using the initial value(12 hours). Eventually, we found the Maxage setter function in the source code. Apparently, to set MaxAge, we should use cstore.Options.Maxage(265400) rather than assigning the value directly.

It took us several hours to dig it out. I think it would be good to add the correct usage in the sample.

@aarondl
Copy link
Member

aarondl commented May 20, 2019

Hopefully the change I made is sufficient. It's worth noting that you may want to be calling MaxAge on the cookiestore itself in your code, otherwise something may be missed (looking at the source code for the method).

@raven-chen
Copy link
Author

awesome! thank you!

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

No branches or pull requests

2 participants