blob: 776fddd88e86cffeb369c5ec9cc7799fa2a9811d (
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
|
package session
import "github.com/gofiber/fiber/v2"
const emailKey = "email"
func CreateSession(ctx *fiber.Ctx, email string) error {
return Set(ctx, emailKey, email)
}
func DestroySession(ctx *fiber.Ctx) error {
return Delete(ctx, emailKey)
}
func GetSessionEmail(ctx *fiber.Ctx) (string, error) {
value, err := Get(ctx, emailKey)
if err != nil || value == nil {
return "", err
}
email, ok := value.(string)
if !ok {
return "", nil
}
return email, nil
}
|