setCookieAttributes sets the cookie attributes based on the session config.
(fcookie *fasthttp.Cookie)
| 547 | |
| 548 | // setCookieAttributes sets the cookie attributes based on the session config. |
| 549 | func (s *Session) setCookieAttributes(fcookie *fasthttp.Cookie) { |
| 550 | // Set SameSite attribute |
| 551 | switch { |
| 552 | case utils.EqualFold(s.config.CookieSameSite, fiber.CookieSameSiteStrictMode): |
| 553 | fcookie.SetSameSite(fasthttp.CookieSameSiteStrictMode) |
| 554 | case utils.EqualFold(s.config.CookieSameSite, fiber.CookieSameSiteNoneMode): |
| 555 | fcookie.SetSameSite(fasthttp.CookieSameSiteNoneMode) |
| 556 | default: |
| 557 | fcookie.SetSameSite(fasthttp.CookieSameSiteLaxMode) |
| 558 | } |
| 559 | |
| 560 | // The Secure attribute is required for SameSite=None |
| 561 | if fcookie.SameSite() == fasthttp.CookieSameSiteNoneMode { |
| 562 | fcookie.SetSecure(true) |
| 563 | } else { |
| 564 | fcookie.SetSecure(s.config.CookieSecure) |
| 565 | } |
| 566 | |
| 567 | fcookie.SetHTTPOnly(s.config.CookieHTTPOnly) |
| 568 | } |
| 569 | |
| 570 | // decodeSessionData decodes session data from raw bytes |
| 571 | // |
no outgoing calls
no test coverage detected