# libtmux.Server.has_session

- **Module:** libtmux.Server
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/9fdd083a8181a827889337b63cd4e6daea661a8c/src/libtmux/server.py#L429
- **Page:** https://libtmux.org/en/py/latest/reference/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`
