A user session, also called a login session, is the bounded period during which an authenticated person interacts with an operating system, together with the kernel and system objects that represent that interaction: an access token or credential set, a desktop or terminal, environment settings and every process started on the person’s behalf. In operating systems, the session is the unit that connects user accounts to running work, which is why it matters for security, resource accounting and clean sign out.
A session begins when authentication succeeds at the login screen, through a remote protocol or by automatic login, and it ends when the person signs out, the system shuts down or an administrator terminates it. Between those two points, the operating system isolates one session from another so that several people, or several service identities, can share one machine without seeing or controlling each other’s programs.
How an operating system creates a user session
Session creation is a chain of privileged steps that turns verified credentials into a working environment. A trusted login component collects the credentials, an authentication service validates them against a local database or a directory, and the system then builds a security context that every later process inherits.
- The login manager (Winlogon with LogonUI on Windows, loginwindow on macOS, a display manager such as GDM or a getty and login pair on Linux) presents the prompt.
- An authentication subsystem such as LSASS, Open Directory or PAM checks the password, smart card, biometric or Kerberos ticket.
- The system assigns a session identifier and creates the access token, credential structure or audit session that carries the user identity and group memberships.
- The user profile and home directory are loaded, environment variables are set and startup programs run.
- The shell or desktop environment starts as the first interactive process, and all child processes inherit the session.
Because each process carries the session identity, the kernel can enforce access control on files, registry keys, devices and inter-process communication without asking the user again. The same mechanism lets the system find and close every process in a session when it ends.
Session types and their properties
Operating systems distinguish several kinds of sessions, and the differences decide what a session may display, which devices it owns and how long it lives. The table below compares the most common types.
| Session type | How it starts | Typical traits |
|---|---|---|
| Interactive console | Sign-in at the local login screen | Owns physical keyboard, display and audio |
| Remote graphical | RDP, VNC or similar protocol | Virtual display, redirected devices |
| Remote terminal | SSH or serial console | Text only, no desktop by default |
| Service or batch | Service manager or scheduler | No user interface, runs under a system account |
| Disconnected | Remote client drops or user locks out | Processes keep running without a display |
On Windows, session 0 isolation reserves session 0 for services since Windows Vista, while interactive users receive session 1 and higher. This separation blocks shatter attacks, in which a low-privilege program sends window messages to a privileged service sharing the same desktop.
How major platforms track sessions
Each platform implements sessions with its own components, yet the underlying model is the same: a session identifier, a security context and a process tree. The following comparison names the parts an administrator meets in practice.
| Platform | Session tracker | Identity carrier | Inspection command |
|---|---|---|---|
| Windows | Session Manager and Terminal Services | Access token with logon SID | query session, qwinsta |
| macOS | loginwindow and launchd | Audit session and per-user launchd domain | who, launchctl print |
| Linux | systemd-logind | UID, GID list and session scope | loginctl list-sessions |
| Traditional Unix | utmp and wtmp records | UID and controlling terminal | who, last |
On Linux, systemd-logind places each session in its own control group, which allows the system to account CPU and memory per session and to kill lingering processes at sign out when the KillUserProcesses option is enabled. On Windows, the logon SID inside the token lets the system grant access to the window station and desktop of exactly one session.
User session compared with related concepts
A user session is often confused with neighboring ideas in the same topic, but each describes a different layer. The account is the identity, the profile is stored data and the session is the live runtime instance of that identity.
| Concept | What it represents | Lifetime |
|---|---|---|
| User account | Identity, credentials and group memberships | Until deleted |
| User profile | Settings, documents and application data | Persistent on disk |
| User session | Running context with token and processes | Sign-in to sign out |
| Web session | Server-side state tied to a cookie | Until timeout or logout |
Fast user switching depends on this distinction: it keeps the first session alive and disconnected while a second user signs in, so two sessions coexist on one machine. A multi-user system generalizes the same idea to many simultaneous local and remote sessions.
Managing session lifetime and security
Administrators control sessions through lock, timeout and termination policies, and the right choice balances convenience against exposure. A locked session keeps programs running but requires authentication to resume, whereas signing out destroys the session and releases its resources.
| Situation | Recommended control | Reason |
|---|---|---|
| Shared office workstation | Screen lock after 5-15 minutes | Limits access by passers-by |
| Remote desktop server | Disconnected session limit | Frees memory and licenses |
| Kiosk or public terminal | Sign out on idle | Removes the previous user’s data |
| Privileged administration | Separate elevated session | Keeps admin rights short-lived |
Session security also depends on how credentials are held. On Windows, cached credentials in LSASS memory can be stolen while a session is active, which is why Credential Guard and short-lived administrator sessions reduce the risk of credential theft and lateral movement.
Common mistakes and failure modes
Most session problems arise from assuming a session ends when it has not, or from mixing contexts. Experienced administrators watch for the following issues.
- Orphaned processes that survive sign out and keep files locked or consume memory.
- Disconnected remote sessions that remain logged in for days and hold privileged tokens.
- Services that try to show a dialog in session 0, which the interactive user never sees.
- Group membership changes that do not apply until a new session begins, because the token is built at sign-in.
- Shared accounts that make it impossible to attribute session activity to one person in audit logs.
In plain words
A user session is the time you spend signed in to a computer, plus everything the computer keeps track of while you are there. When you sign in, the system gives you a kind of visitor badge that every program you open carries with it. That badge says who you are and what you are allowed to touch.
When you sign out, the badge is taken back and your programs are closed. Locking the screen is different: your programs keep running and wait for you to come back. Several people can each have their own session on one computer, and the system keeps them apart.
A real-world example
A small accounting firm runs a Windows remote desktop server for 20 employees. Staff often close the remote window instead of signing out, so their sessions stay disconnected but alive, each holding an open spreadsheet and about 400 MB of memory. By Friday the server has more than 30 lingering sessions and becomes slow, and several shared workbooks stay locked.
The administrator uses query session to list the disconnected sessions, then sets a policy that ends disconnected sessions after two hours and idle active sessions after eight hours. The administrator also adds a nightly report of sessions held by administrator accounts. Within a week, memory use drops by roughly a third, locked-file complaints stop and no privileged session remains open overnight.