# What security protections do Session Settings provide against unauthorized session hijacking?

**Topic:** Admin · **Difficulty:** Medium · **Tags:** Admin, Session Settings, Security Controls

Read it on the site: https://www.forcechallenges.com/interview-questions/what-security-protections-do-session-settings-provide-against-unauthorized-session-hijacking

## Answer

**Basics:** After login Salesforce issues a session ID stored in a cookie. Anyone who steals it (sniffing, XSS, shared computer) can act as the user without a password. Session Settings (Setup > Security > Session Settings) are the org-wide controls that limit that exposure.

**How it works:**
- Timeout value: 15 minutes to 24 hours of inactivity (default 2 hours); a warning popup appears before logout. Profiles can set their own timeout, which overrides the org value.
- Lock sessions to the IP address from which they originated: a request from a different IP invalidates the session.
- Lock sessions to the domain in which they were first used: blocks reuse of the session on other domains.
- Require secure connections (HTTPS): non-HTTPS requests are rejected or redirected; Salesforce enforces TLS today.
- Require HttpOnly attribute: JavaScript cannot read the session cookie, mitigating XSS theft.
- Enable clickjack protection (setup, Visualforce, non-setup pages) and CSRF protection on GET/POST.
- Session security levels (Standard, High Assurance) gate sensitive actions behind MFA: authentication methods map to a level and a profile or connected app can require High Assurance.
- Enforce login IP ranges on every request (instead of only at login), and session-level restrictions via login hours and trusted IP ranges.

**Advanced / deep dive:** IP locking breaks mobile and VPN users whose IP changes, so it is often a trade-off; combine it with MFA, short timeouts and login IP ranges for privileged profiles. Session timeout applies to inactivity, not absolute lifetime, and API/Connected App sessions follow connected app policy (refresh token policy and session policy) rather than UI timeout. Users can be forced out through Setup > Session Management (Active Sessions), and admins can revoke OAuth tokens. Transaction Security Policies and Event Monitoring (LoginEvent, LogoutEvent, SessionHijackingEvent via Shield) detect hijacking: session hijacking detection compares browser fingerprint and IP changes. In Apex, `Auth.SessionManagement` supports step-up (high assurance) and `UserInfo.getSessionId()` should never be logged or sent to third parties.

**Code / config example:**
```
Setup > Security > Session Settings
  Timeout value: 30 minutes
  [x] Lock sessions to the IP address from which they originated
  [x] Lock sessions to the domain in which they were first used
  [x] Require secure connections (HTTPS)
  [x] Require HttpOnly attribute
  [x] Enable clickjack protection for customer Visualforce pages with standard headers
  [x] Enforce login IP ranges on every request
```

**Hidden gotchas & must-remember points:**
- A profile-level timeout overrides the org default.
- IP locking can break legitimate roaming users and shared proxies.
- MFA is mandatory for direct UI logins under Salesforce's contractual requirements; verify current wording.
- Session settings do not govern API tokens or refresh tokens; use Connected App policies.
- Lowering timeout helps shared-kiosk risk, not active-session theft.
- Never expose session IDs in Visualforce/LWC to third-party hosts.

**Best practice:** Combine short timeouts, HttpOnly, HTTPS, MFA and IP restrictions for admin profiles, and monitor with Event Monitoring.

---
Source: ForceChallenges · last updated 2026-11-02
