---
title: "flush(completionHandler:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlsession/flush(completionhandler:)"
---

# flush(completionHandler:)

Flushes cookies and credentials to disk, clears transient caches, and ensures that future requests occur on a new TCP connection.

## Declaration

```swift
func flush(completionHandler: @escaping @Sendable () -> Void)
```

```swift
func flush() async
```

## Parameters

- `completionHandler`: The completion handler to call when the flush operation is complete. This handler is executed on the delegate queue.

## See Also

### Managing the session

- [finishTasksAndInvalidate()](foundation/urlsession/finishtasksandinvalidate().md)
- [getTasksWithCompletionHandler(_:)](foundation/urlsession/gettaskswithcompletionhandler(_:).md)
- [getAllTasks(completionHandler:)](foundation/urlsession/getalltasks(completionhandler:).md)
- [invalidateAndCancel()](foundation/urlsession/invalidateandcancel().md)
- [reset(completionHandler:)](foundation/urlsession/reset(completionhandler:).md)
- [sessionDescription](foundation/urlsession/sessiondescription.md)
