Agent Wranglers

ACC-27Recommended

List every signed-in device

Show each person their active sessions, with device, browser, approximate place, sign-in time and last activity, and mark the current one.

How to do it

Store sessions on the server, one row per sign-in. Give each row a public ID apart from the secret cookie value, so the list never shows a secret. At sign-in, save a label parsed from the user agent, such as "Firefox on Windows". Save a city or country derived from the IP address, not the address. Update last activity at most once every 5 minutes, to save writes. With tokens, keep one row per refresh token family. Each entry rests on locked-down session cookies.

Examples

SQL example

CREATE TABLE sessions (
  id uuid PRIMARY KEY,
  secret_hash bytea NOT NULL UNIQUE,
  user_id uuid NOT NULL REFERENCES users (id) ON DELETE CASCADE,
  device_label text NOT NULL,
  approximate_place text,
  created_at timestamptz NOT NULL DEFAULT now(),
  last_seen_at timestamptz NOT NULL DEFAULT now()
);

How to check

Sign in from two browsers. The list in each shows both, with the right browser names, and marks the current one.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/accounts/sessions-and-security-activity/session-list">Agent Wranglers accounts and identity playbook</a>. In code you write, add a comment next to it with the same link.