Profile session key always empty after login - Golang WebApp

I cloned the repo specified in this tutorial to test it out. The code runs (login/logout works as expected) except the last part which states:
Create a middleware that will check if the user is authenticated or not based on the profile session key
Finally, set up this middleware for any route that needs authentication by adding it to the router.
I tried setting up another route using this middleware but it always redirects like I was not logged in, the profile session key is always nil.

Hey there @tomi.okretic welcome to the community!

I just set this up to test and was experiencing the same thing - In my case I included another button on my user.html but was including the btn-logout class similar to the logout button. That was calling user.js which was clearing my session so you’ll want to make sure you aren’t calling this anywhere:

$(document).ready(function() {
    $('.btn-logout').click(function(e) {

Removing btn-logout from my new button did the trick for me - Perhaps you are doing something similar?

Let us know!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.