Question: How to set httponly cookie in response
BrucePeng92 opened this issue · comments
CyberPunL commented
I want to set the token as a cookie. How can I set it as a response using HTTPonly ?
Ernest Micklei commented
something like this, accessing the embedded ResponseWriter directly.
yourCookie := &http.Cookie{
Name: "somename",
Value: "somevalue"
HttpOnly: true
}
http.SetCookie( restfulResponse.ResponseWriter, yourCookie )
CyberPunL commented
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"?
CyberPunL commented
It works, thanks again.