markbates/goth

StoreInSession calls Store.New creating a new session every time

TomG-Mona opened this issue · 1 comments

err := gothic.StoreInSession("test", "test-value, req, res)
if err != nil {
	fmt.Println("error storing client in session: ", err)
            return
}

val, err := GetFromSession("test", req)
if err != nil {
	fmt.Println("error retrieving value for 'test' that was just set: ", err)
   }

  // GetFromSession fails 100% of the time

I am having this same issue. For me it is setting the cookies path to the current path which deletes it right away.

If I manually set the path using the session store it will set a cookie and keep it. However if you try and call it again right after to populate the value it will reset the path.

StoreInSession("path", "/", r, w)

This will create a cookie with a path "/" and it will persist.

StoreInSession("value", "somevalue", r, w)

The previous cookie is overwritten and the current path written which deletes the cookie instantly