Answer the question
In order to leave comments, you need to log in
How to properly declare a variable so that all functions have access to it?
hello there is a function
func checksession() {
session, err := store.Get(r, "infoUs")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
func RenderMainAdmin(w http.ResponseWriter, r *http.Request) {
id := session.Values["id"]
if id == nil {
fmt.Println("Nil")
http.Redirect(w, r, "/, http.StatusSeeOther)
return
} else {
fmt.Println("Id", id)
}
}
Answer the question
In order to leave comments, you need to log in
var session *sessions.Session
/*-------------------------------------------------------*/
func checksession() {
var err error
session, err = store.Get(r, "infoUs")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question