Cookie

Set cookie

  1. func (c *Ctx) Cookie(cookie *Cookie)
  1. type Cookie struct {
  2. Name string
  3. Value string
  4. Path string
  5. Domain string
  6. Expires time.Time
  7. Secure bool
  8. HTTPOnly bool
  9. SameSite string // lax, strict, none
  10. }
  1. app.Get("/", func(c *fiber.Ctx) error {
  2. // Create cookie
  3. cookie := new(fiber.Cookie)
  4. cookie.Name = "john"
  5. cookie.Value = "doe"
  6. cookie.Expires = time.Now().Add(24 * time.Hour)
  7. // Set cookie
  8. c.Cookie(cookie)
  9. // ...
  10. })