好的,從哪里開始...問題是,當我設置會話是Path到"/"會話不會得到保存。我設置Path是因為當發(fā)布到不是保存會話的路徑的路徑時,也session.Save()稱為會話值“用戶”為空|nil|未設置。所以我設置了Path: "/",但會話沒有保存。檢查 Chromium 時,我看到 cookie 已設置。我不知道問題出在哪里。是在大猩猩/會議中嗎?是在 AngularJS 中嗎?HTML5 模式在 angular 中處于關閉狀態(tài)。所以改寫一下,發(fā)生這種情況是因為與調用函數(shù)的/api/1.0/community路徑不同,這就是我設置. 但是,當是會話值“用戶”不會被保存。/api/1.0/usersessions.Save(r,w)Path: "/",Path"/"main.govar ( sessionStore *sessions.CookieStore sessionAuthKey []byte = make([]byte, 64) sessionCryptKey []byte = make([]byte, 32) router *mux.Router = mux.NewRouter())func init() { // Generate Session Secret sessionAuthKey = securecookie.GenerateRandomKey(64) sessionCryptKey = securecookie.GenerateRandomKey(32) // Create Session sessionStore = sessions.NewCookieStore(sessionAuthKey, sessionCryptKey) sessionStore.Options = &sessions.Options{ Domain: ".mango.dev", Path: "/", MaxAge: 0, }}func main() { api := router.PathPrefix("/api/1.0").Subrouter() api.HandleFunc("/user/register", UserRegisterHandler).Methods("POST") api.HandleFunc("/user/authenticate", UserAuthenticateHandler).Methods("POST") api.HandleFunc("/user/endsession", UserLogoutHandler).Methods("POST") api.HandleFunc("/user/profile", UserProfileHandler).Methods("GET") api.HandleFunc("/user/profile", UserUpdateProfileHandler).Methods("POST") api.HandleFunc("/user/reset_request", UserResetRequestHandler).Methods("POST") api.HandleFunc("/user/reset_password", UserResetPasswordHandler).Methods("POST") api.HandleFunc("/user/loginstatus", UserLoginStatusHandler).Methods("GET") api.HandleFunc("/forums/directory", ForumsDirectoryHandler).Methods("GET") api.HandleFunc("/community/list", CommunityListHandler).Methods("GET") api.HandleFunc("/community/show", CommunityShowHandler).Methods("GET") api.HandleFunc("/community/create", CommunityCreateHandler).Methods("POST") api.HandleFunc("/community/edit", CommunityEditHandler).Methods("GET")
go gorilla/sessions angularjs 和路徑,未保存會話值(找到錯誤/歸咎于)
慕碼人8056858
2021-07-09 14:19:53