gorilla/session的使用求指教..以下为官方example
import (
"net/http"
"github.com/gorilla/sessions"
)
var store = sessions.NewCookieStore([]byte("something-very-secret"))
func MyHandler(w http.ResponseWriter, r *http.Request) {
// Get a session. We're ignoring the error resulted from decoding an
// existing session: Get() always returns a session, even if empty.
session, _ := store.Get(r, "session-name")
// Set some session values.
session.Values["foo"] = "bar"
session.Values[42] = 43
// Save it.
session.Save(r, w)
}
代码里something-very-secret应该就是session的加密码..而store.Get(r,"session-name")这个session-name是不是我们常说的sessionid?
有疑问加站长微信联系(非本文作者)