Gin: Ask: How to get and set Cookie from gin.Context?

Created on 1 Dec 2014  路  4Comments  路  Source: gin-gonic/gin

How to get and set Cookie from gin.Context?
Also, how to get User-Agent, Client's IP Address?

Most helpful comment

Use http.Request.Cookie(cookiename) to get cookie, and http.SetCookie(gin.Context.Writer, &http.Cookie) to set cookie,
You can find http header in gin.Context.Request that same as http.Request.

All 4 comments

Use http.Request.Cookie(cookiename) to get cookie, and http.SetCookie(gin.Context.Writer, &http.Cookie) to set cookie,
You can find http header in gin.Context.Request that same as http.Request.

ok, thanks :3

ah wait, should I worry when "User-Agent" from client was sent as "user-agent" ?
would I still get the correct one when get it from gin.Context.Request?

Got an answer already, thanks :3

http://stackoverflow.com/questions/27234861

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mastrolinux picture mastrolinux  路  3Comments

frederikhors picture frederikhors  路  3Comments

oryband picture oryband  路  3Comments

rawoke083 picture rawoke083  路  3Comments

kekemuyu picture kekemuyu  路  3Comments