Golang net/http/cookiejar.New(), Cookies() and SetCookies() functions example
Example 1:
jar, _ := cookiejar.New(nil)
Example 2:
var cookies []*http.Cookie
...
fourthCookie := &http.Cookie{
Name: "dkv",
Value: "19a17a80fd703efd450d5ef9dadc32cee3QEAAAAdGxpcGn9mTBVMA==",
Path: "/",
Domain: ".youtube.com",
}
cookies = append(cookies, fourthCookie)
// URL for cookies to remember. i.e reply when encounter this URL
cookieURL, _ := url.Parse("https://www.youtube.com/results?search_query=")
jar.SetCookies(cookieURL, cookies)
Example 3:
fmt.Println(jar.Cookies(cookieURL))
See also : https://www.socketloop.com/tutorials/golang-storing-cookies-in-http-cookiejar-example
References :
http://golang.org/pkg/net/http/cookiejar/#New
Advertisement
Something interesting
Tutorials
+32.2k Golang : Convert []string to []byte examples
+9.6k Golang : Read file with ioutil
+8.9k Golang : Sort lines of text example
+10.6k Golang : How to delete element(data) from map ?
+6k Linux/MacOSX : Search for files by filename and extension with find command
+5.4k Unix/Linux/MacOSx : How to remove an environment variable ?
+5.3k PHP : Hide PHP version information from curl
+10.2k Golang : Use regular expression to get all upper case or lower case characters example
+18.4k Golang : How to remove certain lines from a file
+14.2k Golang : Fix image: unknown format error
+37.5k Upload multiple files with Go
+20.2k Golang : Reset or rewind io.Reader or io.Writer