title: How to GET Request with Cookie After login
body: <p>I tried to get some resp.Body of jadwalURL. jadwalURL can be access after login, so I add the Cookie header to the request. But Sadly the response is not quite that I want (response is home page). I tried this similiar flow with Postman. and I got the jadwalURL body as i wanted. Is there anything wrong with my code? I still dont get the solution after 3 hours searching.</p>
  <pre class="lang-golang prettyprint-override"><code>func main() {
      data := url.Values{}
      data.Set(&quot;username&quot;, username)
      data.Set(&quot;password&quot;, password)
      client := &amp;http.Client{}
      r, _ := http.NewRequest(http.MethodPost, loginURL, strings.NewReader(data.Encode()))
      r.Header.Add(&quot;Content-Type&quot;, &quot;application/x-www-form-urlencoded&quot;)
      resp, _ := client.Do(r)
      cookie := resp.Cookies()
      fmt.Println(cookie)
      fmt.Println(resp.Status)
  
      req, err := http.NewRequest(http.MethodGet, jadwalURL, nil)
      if err != nil {
          panic(err)
      }
  
      req.AddCookie(&amp;http.Cookie{
          Name:   cookie[0].Name,
          Value:  cookie[0].Value,
          Domain: domainURL,
          Path:   &quot;/&quot;,
      })
  
      jadwalResp, err := http.DefaultClient.Do(req)
      if err != nil {
          panic(nil)
      }
      body, _ := ioutil.ReadAll(jadwalReq.Body)
      jadwalResp.Body.Close()
      fmt.Println(string(body))
  }
  </code></pre>