Sub topic 8
Session settings and session security levels
This chapter assumes you can navigate Setup and know how profiles and permission sets assign settings to users. It also assumes you have read the earlier chapters on MFA and on enabling it. MFA controls how a user proves who they are at login. Session settings control what happens afterward, while the browser holds a live session ID. A stolen session ID is as valuable to an attacker as a stolen password, so both layers matter.
What a session is
When a user logs in, Salesforce creates a session. The session is identified by a token stored in a browser cookie, and every later request sends that token. Salesforce does not ask for the password again, so anyone who holds the token acts as that user until the session ends.
Session settings reduce that risk in three ways:
- They shorten how long a session can live.
- They bind a session to a place, such as an IP address or a domain.
- They require stronger proof of identity for sensitive resources, which is what session security levels do.
Session Settings in Setup
Open Setup, search for Session Settings, and review the page. The settings below are the ones that matter most.
| Setting | What it does | Trade-off |
|---|---|---|
| Timeout value | Ends a session after a period of inactivity. Choices run from 15 minutes to 24 hours. | Shorter is safer but interrupts users. |
| Force logout on session timeout | Sends the user back to the login page when the session expires. | Users lose unsaved work on timeout. |
| Lock sessions to the IP address from which they originated | Rejects requests from a different IP than the one used at login. | Breaks sessions for users on mobile networks or behind rotating proxies. |
| Lock sessions to the domain in which they were first used | Stops a session ID from working on another domain. | Rarely causes problems. Enable it. |
| Require secure connections (HTTPS) | Rejects HTTP requests. | Enabled by default. |
| Require HttpOnly attribute | Hides the session cookie from client-side scripts. | Custom code that reads the cookie will stop working. |
| Enable clickjack protection | Blocks pages from being framed by other sites. | Review it if you embed pages in external sites. |
| Enforce login IP ranges on every request | Applies profile login IP ranges to every request, not only at login. | Covered in the chapter on network restrictions. |
The timeout is an inactivity timer, not a fixed lifetime. Any activity that reaches the server resets it. A user who keeps working can stay logged in far longer than the timeout value. Salesforce shows a warning about 30 seconds before the session expires, and the user can click to stay logged in.
Profile overrides
The org-wide timeout is the default. A profile can set its own Session times out after value in the profile's Session Settings. Use this to give a high-risk group, such as finance or system administrators, a shorter timeout than everyone else. Salesforce applies the profile value to users with that profile.
Session security levels
Every session has a security level. There are two:
- Standard: the session was created with an ordinary login method.
- High Assurance: the session was created with a stronger login method, usually one that includes MFA.
The level belongs to the session, not to the user. The same person can have a Standard session on one device and a High Assurance session on another.
Assigning levels to login methods
Under Session Settings, find the Session Security Levels section. It lists login methods in two boxes, Standard and High Assurance. You move each method into the box you want. Methods include username and password, delegated authentication, authentication providers used for SSO, and the MFA verification methods you registered in earlier chapters.
This list decides what level a session gets at login. By default, a username and password login gives a Standard session, and a login that completes MFA can be placed in High Assurance. Check your org's list rather than assuming. Salesforce has changed the available methods over time.
Requiring a level
Assigning levels has no effect until something requires one. You can require High Assurance in these places:
- Profile: set Session security level required at login to High Assurance. Users with that profile must reach that level to finish logging in. If their login method only earns Standard, Salesforce prompts them to verify their identity, usually with MFA.
- Connected app: select High assurance session required in the app's policies. Users with a Standard session are prompted before the app is authorized.
- Session-based permission sets: a permission set can be activated only for the session, and only when the session has High Assurance. Users get the powerful permissions only after they have verified with MFA.
The third option applies least privilege to sessions. A user holds an ordinary role day to day. Sensitive permissions, such as exporting data or managing users, turn on only after a stronger login.
Checking session levels with a query
You can read session data with SOQL. The AuthSession object has one record per active session, including its level and how long it is valid. This query lists the current sessions, newest first, and shows which are Standard and which are High Assurance.
SELECT UsersId, SessionType, LoginType, SessionSecurityLevel, SourceIp, NumSecondsValid, CreatedDate
FROM AuthSession
ORDER BY CreatedDate DESC
LIMIT 100Use it to confirm that a profile or connected app setting works. Log in as a test user, run the query, and check that the new session shows the level you expect. You can also check whether any session lasts longer than your policy intends by comparing NumSecondsValid with your timeout. Like login history, session data is limited by what your user can view, so run the query with an administrator account that has the relevant permissions.
Managing live sessions
Settings take effect when a session is created or on its next request, but sometimes you need to end a session now. For example, a user reports a lost laptop. In Setup, open Session Management to see active sessions with their location, login type, and level. Select a session and choose Revoke, and that session stops working. A user can also see and revoke their own sessions from their personal settings.
Revoking sessions is the first step when an account may be compromised. Follow it with a password reset and a review of registered verification methods. The chapter on account recovery covers that flow.
Common errors and gotchas
- Users are logged out constantly after enabling IP locking. The user's IP address changes during the session, which is normal on mobile networks and some corporate proxies. Remove the lock or move those users to a profile that does not need it.
- High Assurance is required, but users are never prompted. The login method may already be assigned to High Assurance, so the session meets the requirement at login. Check the Session Security Levels list.
- A profile requires High Assurance and users cannot log in. The user has no registered verification method, so they cannot reach the higher level. Make sure users register a method before you enforce the requirement.
- The org timeout and the profile timeout disagree. The profile value wins for users with that profile. Check the profile first when a user's timeout looks wrong.
- Changes seem not to apply. Existing sessions keep the level they were created with. Ask users to log out and back in, or revoke their sessions, to test a change.
Putting it together
A reasonable baseline for most orgs is:
- Keep HTTPS, HttpOnly, and clickjack protection on.
- Lock sessions to the domain.
- Choose a timeout your users can live with, and set a shorter one on profiles for sensitive roles.
- Place the MFA login methods in High Assurance, then require High Assurance on the profiles, connected apps, and session-based permission sets that guard sensitive data.
- Check the result with
AuthSessionafter each change.
Exercise
A user logs in with only a username and password. Their profile requires a High Assurance session at login, and no verification method is assigned to High Assurance except MFA. What happens, and why can this lock out a new user?
Show answer
Salesforce sees that the session level from the username and password login is Standard, so it prompts the user to verify with MFA to raise the session to High Assurance. If the user has not registered a verification method, they cannot complete the prompt and cannot finish logging in. Register users' verification methods before you enforce the required session level on their profile.
Exercise
You turn on "Lock sessions to the IP address from which they originated," and field staff on mobile data report being logged out several times a day. What is the likely cause, and what are two ways to fix it?
Show answer
Their IP address changes during the session, as mobile carriers often reassign addresses, and the changed address makes Salesforce reject the session. You can disable IP locking for the org, or you can keep it on for most users and give the field staff a separate arrangement. Rely on other controls for them, such as MFA, a shorter timeout, and the domain lock.