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

Comments

Projects
None yet
4 participants
@yandd
Copy link

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

This comment has been minimized.

Copy link
Member

commented May 19, 2016

@nigeltao, are you still the cookie monster?

@nigeltao

This comment has been minimized.

Copy link
Contributor

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?

@yandd

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Author

commented May 19, 2016

@nigeltao thank you

@yandd yandd closed this 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.
You can’t perform that action at this time.