# pane.Pane.session

- **Module:** pane.Pane
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/pane.rs#L463
- **Page:** https://libtmux.org/en/rs/latest/reference/pane-pane-session/

```
pane.Pane.session(self) -> Result<Option<Session>, Error>
```

Return the session this pane was reached through.

This re-reads tmux rather than the snapshot, so a session renamed or
removed since discovery is reported as it is now. `Ok(None)` means the
session no longer exists.

A window can be linked into several sessions, so this is the session
this handle was reached through rather than the pane's only one; the
pane itself belongs to exactly one window.

# Errors

Returns an error when the session listing fails.

## Example

```rust
if let Some(session) = pane.session().await? {
    println!("{}", session.name().to_string_lossy());
}
```
