package main
import (
"github.com/gorilla/sessions"
"net/http"
"os"
)
var store sessions.Store
// var store = sessions.NewCookieStore([]byte("something-very-secret"))
var abc string
func pageHandler(w http.ResponseWriter, r *http.Request) {
session, _ := store.Get(r, "get_name_session")
Name := session.Values["name"].(string)
session.Values["name"] = "Dean"
session.Save(r, w)
println("操作数据库成功2!")
println(string(Name))
}
func UserValid(w http.ResponseWriter, r *http.Request) {
}
func main() {
store = sessions.NewCookieStore([]byte(os.Getenv("KEY")))
http.HandleFunc("/", pageHandler)
http.ListenAndServe(":7888", nil)
}
怎么在UserValid这个函数接受在pageHandler定义的session的值?求大神解答
有疑问加站长微信联系(非本文作者)