Package gorilla/sessions provides cookie and filesystem sessions and infrastructure for custom session backends.
If you want to persist some form of context between requests you can store it in session data via a cookie that can be pulled/leveraged in the second handler, ex: https://github.com/gorilla/sessions. If you try to implement it yourself consider security aspects like that a user could modify if unsigned, etc. You can also store data server side and just issue a token in a cookie corresponding to a server side session. Hope that helps.
Golang API Authentication using JWT Tokens
1 project | reddit.com/r/golang | 29 Mar 2021
My first Reddit post & Go module!
3 projects | reddit.com/r/golang | 7 Jun 2022
Build a REST API with Golang and MongoDB - Gorilla/Mux Version
2 projects | dev.to | 2 Jan 2022
I learnt how to use WebSockets, made something beautiful/terrible
1 project | news.ycombinator.com | 29 Dec 2021
The Gorilla Toolkit Is Looking for a New Maintainer
1 project | news.ycombinator.com | 13 Dec 2021