---
title: "withSession(_:)"
framework: cryptotokenkit
role: symbol
role_heading: Instance Method
path: "cryptotokenkit/tksmartcard/withsession(_:)"
---

# withSession(_:)

Synchronously begins a session, executes the given closure, and ends the session.

## Declaration

```swift
func withSession<T>(_ body: @escaping () throws -> T) throws -> T
```

## Parameters

- `body`: A closure to be called in the context of the created session.

## See Also

### Transmitting Data

- [send(ins:p1:p2:data:le:reply:)](cryptotokenkit/tksmartcard/send(ins:p1:p2:data:le:reply:).md)
