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

Method RegenerateWithContext

middleware/session/session.go:255–270  ·  view source on GitHub ↗

RegenerateWithContext generates a new session id and deletes the old one from storage, using the provided context for cancellation and timeout control. Parameters: - ctx: The context to use for the storage operation. Returns: - error: An error if the regeneration fails. Usage: err := s.Regenera

(ctx context.Context)

Source from the content-addressed store, hash-verified

253//
254// err := s.RegenerateWithContext(ctx)
255func (s *Session) RegenerateWithContext(ctx context.Context) error {
256 ctx = backgroundIfNil(ctx)
257
258 s.mu.Lock()
259 defer s.mu.Unlock()
260
261 // Delete old id from storage
262 if err := s.config.Storage.DeleteWithContext(ctx, s.id); err != nil {
263 return err
264 }
265
266 // Generate a new session, and set session.isFresh to true
267 s.refresh()
268
269 return nil
270}
271
272// Reset generates a new session id, deletes the old one from storage, and resets the associated data.
273//

Calls 5

refreshMethod · 0.95
backgroundIfNilFunction · 0.85
LockMethod · 0.65
UnlockMethod · 0.65
DeleteWithContextMethod · 0.65