aboutsummaryrefslogtreecommitdiff
path: root/src/sessions/sessions.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/sessions/sessions.go')
-rw-r--r--src/sessions/sessions.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/sessions/sessions.go b/src/sessions/sessions.go
new file mode 100644
index 0000000..d2acab6
--- /dev/null
+++ b/src/sessions/sessions.go
@@ -0,0 +1,35 @@
+package sessions
+
+import (
+ "net/http"
+
+ "github.com/google/uuid"
+)
+
+type SessionMgr struct {
+ key string
+ Values map[string]string
+}
+
+type session map[string]any
+
+type SessionCtxKey string
+
+var sessions map[string]session
+
+func (sm *SessionMgr) NewSession(w http.ResponseWriter, r http.Request) {
+ token := uuid.NewString()
+
+ // set secure cookie in http.ResponseWriter
+ // TODO make secure
+ http.SetCookie(w, &http.Cookie{
+ Name: "session_token",
+ Value: token,
+ })
+
+ sessions[token] = session{
+ "username": username,
+ }
+ // set request context
+
+}