aboutsummaryrefslogtreecommitdiff
path: root/src/sessions/sessions.go
blob: d2acab62c7742fd98aa405ff48b4981aba90a61e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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

}