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

net/http: SetCookie 'Max-Age' field can not be empty #15742

Closed
yandd opened this issue May 19, 2016 · 4 comments
Closed

net/http: SetCookie 'Max-Age' field can not be empty #15742

yandd opened this issue May 19, 2016 · 4 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@yandd
Copy link

yandd commented May 19, 2016

I need to set a cookie which expired after closing browser.
Chrome browser just work well when 'Max-Age' field is empty.
So I think "http.SetCookie" function must support 'Max-Age' field to keep empty.

@bradfitz bradfitz changed the title net/http: http.SetCookie() 'Max-Age' field can not be empty net/http: SetCookie 'Max-Age' field can not be empty May 19, 2016
@bradfitz bradfitz added this to the Go1.8Maybe milestone May 19, 2016
@bradfitz
Copy link
Contributor

@nigeltao, are you still the cookie monster?

@nigeltao
Copy link
Contributor

nigeltao commented May 19, 2016

I'm a little confused as to what the original post is asking for. http.SetCookie takes a *Cookie as an argument, and the Cookie struct type has a MaxAge field.

https://golang.org/pkg/net/http/#Cookie says:

    // MaxAge=0 means no 'Max-Age' attribute specified.
    // MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
    // MaxAge>0 means Max-Age attribute present and given in seconds
    MaxAge   int

Do either of the first two do what you want?

@bradfitz bradfitz added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 19, 2016
@yandd
Copy link
Author

yandd commented May 19, 2016

http://tools.ietf.org/html/rfc6265#section-4.1.2.2
“If a cookie has neither the Max-Age nor the Expires
attribute, the user agent will retain the cookie until "the current
session is over" (as defined by the user agent).”

@yandd
Copy link
Author

yandd commented May 19, 2016

@nigeltao thank you

@yandd yandd closed this as completed May 19, 2016
@bradfitz bradfitz removed this from the Go1.8Maybe milestone May 19, 2016
@golang golang locked and limited conversation to collaborators May 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants