markbates / goth

Package goth provides a simple, clean, and idiomatic way to write authentication packages for Go web applications.
https://blog.gobuffalo.io/goth-needs-a-new-maintainer-626cd47ca37b
MIT License
5.45k stars 587 forks source link

StoreInSession calls Store.New creating a new session every time #527

Open TomG-Mona opened 10 months ago

TomG-Mona commented 10 months ago
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
tmstorm commented 9 months ago

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