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)
| 253 | // |
| 254 | // err := s.RegenerateWithContext(ctx) |
| 255 | func (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 | // |