emicklei / go-restful

package for building REST-style Web Services using Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: How to set httponly cookie in response

BrucePeng92 opened this issue · comments

I want to set the token as a cookie. How can I set it as a response using HTTPonly ?

something like this, accessing the embedded ResponseWriter directly.

yourCookie := &http.Cookie{
    Name: "somename",
    Value: "somevalue"
    HttpOnly: true
}
http.SetCookie( restfulResponse.ResponseWriter, yourCookie )

Thanks for your reply. I used "WS. Route" as the service route. Is there a way to set cookies in this method?

In "restful. Routefunction", can I set cookies by running "http.SetCookie"?

It works, thanks again.