package main import ( "fmt" "net/http" "github.com/vladimirok5959/golang-server-sessions/session" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { // Create new or load saved session var sess *session.Session var err error sess, err = session.New(w, r, "./tmp") if err != nil { fmt.Printf("%s\n", err.Error()) } defer sess.Close() if r.URL.Path == "/" { var counter int // Get value or set default if sess.IsSetInt("counter") { counter = sess.GetInt("counter", 0) } else { counter = 0 } // Increment value counter++ // Update sess.SetInt("counter", counter) w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") w.Header().Set("Content-Type", "text/html") if _, err := w.Write([]byte(`