MCPcopy
hub / github.com/gofiber/fiber / delSession

Method delSession

middleware/session/session.go:513–546  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

511}
512
513func (s *Session) delSession() {
514 if s.ctx == nil {
515 return
516 }
517
518 // Get all relevant extractors
519 relevantExtractors := s.getExtractorInfo()
520
521 // Delete session ID for each extractor type
522 for _, ext := range relevantExtractors {
523 switch ext.Source {
524 case extractors.SourceHeader:
525 s.ctx.Request().Header.Del(ext.Key)
526 s.ctx.Response().Header.Del(ext.Key)
527 case extractors.SourceCookie:
528 s.ctx.Request().Header.DelCookie(ext.Key)
529 s.ctx.Response().Header.DelCookie(ext.Key)
530
531 fcookie := fasthttp.AcquireCookie()
532
533 fcookie.SetKey(ext.Key)
534 fcookie.SetPath(s.config.CookiePath)
535 fcookie.SetDomain(s.config.CookieDomain)
536 fcookie.SetMaxAge(-1)
537 fcookie.SetExpire(time.Now().Add(-1 * time.Minute))
538
539 s.setCookieAttributes(fcookie)
540 s.ctx.Response().Header.SetCookie(fcookie)
541 fasthttp.ReleaseCookie(fcookie)
542 default:
543 // For non-cookie/header sources, do nothing (read-only)
544 }
545 }
546}
547
548// setCookieAttributes sets the cookie attributes based on the session config.
549func (s *Session) setCookieAttributes(fcookie *fasthttp.Cookie) {

Callers 2

DestroyWithContextMethod · 0.95
ResetWithContextMethod · 0.95

Calls 9

getExtractorInfoMethod · 0.95
setCookieAttributesMethod · 0.95
SetPathMethod · 0.80
DelMethod · 0.65
RequestMethod · 0.65
ResponseMethod · 0.65
AddMethod · 0.65
NowMethod · 0.45
SetCookieMethod · 0.45

Tested by

no test coverage detected