# libtmux.Window.linked_sessions

- **Module:** libtmux.Window
- **Package:** libtmux
- **Language:** Python
- **Kind:** property
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/window.py#L306
- **Page:** https://libtmux.org/reference/py/libtmux-window-linked_sessions/

```
libtmux.Window.linked_sessions(self) -> QueryList[Session]
```

Every session this window is reachable from.

Usually one, and then this is just :attr:`Window.session` in a list.
``link-window`` and grouped sessions (``tmux new-session -t existing``)
make it more: the window is genuinely in each of them at once, and
:attr:`Window.session` returns the session recorded on this
:class:`Window` instance.

Each session is listed once, however many indexes it links the window
at, and they come back in the order tmux lists them. Fetching the
holders takes two list commands total, independent of how many there
are.
If either listing fails, the result is empty.

## Returns

:class:`~libtmux._internal.query_list.QueryList` of :class:`~libtmux.Session`

## Example

A window you just made belongs to the session you made it in:

```python
>>> window = session.new_window(window_name="solo", attach=False)
>>> [s.session_name for s in window.linked_sessions] == [session.session_name]
True
```

## Example

Link it into a second session and it belongs to both:

```python
>>> guest = server.new_session(session_name="guest")
>>> target = f"{guest.session_id}:"
>>> _ = server.cmd("link-window", "-d", "-s", window.window_id, "-t", target)
>>> sorted(s.session_name for s in window.linked_sessions) == sorted(
...     [session.session_name, "guest"]
... )
True
```
