# libtmux.Server.has_session

- **Module:** libtmux.Server
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/server.py#L429
- **Page:** https://libtmux.org/reference/py/libtmux-server-has_session/

```
libtmux.Server.has_session(self, target_session: str, exact: bool = True) -> bool
```

Return True if session exists.

## Parameters

- `self`
- `target_session` (str) — session name
- `exact` (bool) — match the session name exactly. tmux uses fnmatch by default.
Internally prepends ``=`` to the session in ``$ tmux has-session``.

## Returns

bool

## Raises

- `exc.BadSessionName`
