Setting cookies with net/http

前端 未结 7 1452
说谎
说谎 2020-12-12 23:12

I\'m trying to set cookies with Go\'s net/http package. I have:

package main

import \"io\"
import \"net/http\"
import \"time\"

func indexHandler(w http.Res         


        
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 23:57

    I am not a Go expert, but I think you are setting the cookie on the request, aren't you? You might want to set it on the response. There is a setCookie function in net/http. This might help: http://golang.org/pkg/net/http/#SetCookie

    func SetCookie(w ResponseWriter, cookie *Cookie)
    

提交回复
热议问题