# server.Server.sessions

- **Module:** server.Server
- **Package:** @libtmux/libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/2cb93308200da38a26b59876618116850f110607/packages/libtmux/src/server.ts#L441
- **Page:** https://libtmux.org/reference/ts/server-server-sessions/

```
server.Server.sessions() -> Promise<Selection<Session>>
```

Every session on the server, read now.

This and its three siblings each take a snapshot of their own — one daemon
identity read and four listings per call — so calling several in a row
describes several different instants and pays for each. Inside a loop that
is an N+1: prefer one
{@link snapshot} and read `sessions`, `windows`, `panes`, and `clients`
off it, which is both cheaper and consistent.

## Example

```ts
// One invocation, and every collection agrees with the others.
const now = await server.snapshot();
for (const session of now.sessions) console.log(session.name, session.windows.length);
```

## Example

```ts
const sessions = await server.sessions();
sessions.where({ name: "work" }).count();
```
