Go HTTP Post and use Cookies

前端 未结 4 986
梦毁少年i
梦毁少年i 2020-12-01 04:07

I\'m trying to use Go to log into a website and store the cookies for later use.

Could you give example code for posting a form, storing the cookies, and accessing a

4条回答
  •  情话喂你
    2020-12-01 04:10

    Another way of doing it. Works in Go 1.8.

        expiration := time.Now().Add(5 * time.Minute)
        cookie := http.Cookie{Name: "myCookie", Value: "Hello World", Expires: expiration}
        http.SetCookie(w, &cookie)
    

提交回复
热议问题