-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
by tg8866:
[code] package main import ( "fmt" "http" "io/ioutil" ) func main() { var req http.Request url, err := http.ParseURL("http://localhost/info.php";) if err != nil { panic(err) } req.URL = url req.Method = "GET" ck1 := new(http.Cookie) ck2 := new(http.Cookie) ck1.Name = "go1" ck1.Value = "hello go1" ck2.Name = "go2" ck2.Value = "hello go2" req.Cookie = append(req.Cookie, ck1) req.Cookie = append(req.Cookie, ck2) resp, err := http.DefaultClient.Do(&req) if err != nil { panic(err) } defer resp.Body.Close() str, err := ioutil.ReadAll(resp.Body) if err != nil { panic(err) } fmt.Printf("%s", str) } [/code] in the info.php [code] <?php print_r($_COOKIE); //just print out the cookies [/code] we run the go code,get output: [code] Array ( [go1] => hello go1, go2=hello go2 ) [/code] that is just one cookie set,and it's wrong cookie go1 mis set to "hello go1, go2=hello go2" --------------------------------------------------- os:windows arch:386 8g -V:8g version release.r57.1 8330 --------------------------------------------------- thanks!