Secure cookies in OutSystems: sessions, Secure, HttpOnly and SameSite
Login in OutSystems relies on cookies. Knowing which ones exist, how the platform validates each request and where to turn on the Secure flag answers a good share of the "Session Cookies" questions in the Security Specialist exam, and prevents a real problem: session theft on insecure networks.
The two authentication cookies
When a user logs in, the server sends two cookies, whose names include the User Provider name:
| Cookie | What it's for | HttpOnly |
|---|---|---|
nr1<User Provider> |
ensures the session is authentic and lets the server control expiration | yes: JavaScript can't read it |
nr2<User Provider> |
tells the app who is logged in (GetUserId) and carries the anti-CSRF data |
no: the app needs to read it |
Don't make nr2 HttpOnly: apps stop working properly.
How each request is validated
On every server call, the app sends both cookies and a token in the X-CSRF-Token header. The server checks that the header and both cookies are present, that the cookie contents are authentic and that the login hasn't expired. If something is missing, the request is treated as anonymous; if anything was tampered with, it fails.
Session timeouts
They live in Service Center → Administration → Security → Applications Authentication, not in Service Studio:
| Setting | Meaning |
|---|---|
| Cache Time In Minutes | how many minutes the server trusts the cookies without checking the database (0 turns it off) |
| Max Idle Time (minutes) | maximum time between server calls for the session to stay valid |
| Max Idle Time (days) | how many days a persistent login stays valid on the server without communication |
| Cookie Expiration (days) | how many days the persistent cookie stays valid in the app without talking to the server |
Watch the cache: requests within the cache period don't renew the session. With a 10-minute Max Idle Time and a 5-minute cache, a call at minute 3 extends nothing. That's why the recommendation is to keep the cache at a small fraction of Max Idle Time, such as 20%. And with a cache above 0, logging out doesn't end the user's other sessions until the cache expires.
The same screen lets you generate new keys for the cookies, forcing everyone to log in again. Useful if you suspect the keys leaked.
The Secure flag
The Secure flag makes the browser send the cookie only over HTTPS. Without it, someone listening on the network can capture the session cookie and impersonate the user (session hijacking).
For the platform's cookies:
- in current versions, turn on the Secure option in LifeTime (each environment's Environment Security) or in Service Center → Administration → Security. The SameSite option is there too;
- when you turn it on, force HTTPS on every screen, with HSTS or "Force HTTPS for Screens", or you'll get session problems (see HSTS vs CSP in OutSystems);
- in older Platform Server versions (before 11.0.614), this was done with the Factory Configuration component from Forge. Older materials still mention that path.
For cookies your app creates: in a Server Action, use SetCookie with CookieSecure = True (from Platform Server 11.7.0; before that, append ; Secure to the value).
Secure, HttpOnly and SameSite
| Flag | What it does |
|---|---|
| Secure | the browser only sends the cookie over HTTPS |
| HttpOnly | the page's JavaScript can't read the cookie |
| SameSite | controls whether the cookie is sent on requests coming from other sites |
What comes built in
- The session identifier changes on every login, which prevents session fixation.
- It never goes in the URL.
- Logging out ends all sessions in that browser.
In ODC, sessions are handled by the Identity Service, and HTTPS and HSTS are on by default. The concepts of secure cookies and expiration apply just the same.
How it shows up in the exam
"Session Cookies" is worth 2 questions within Authentication. The traps:
- Secure ≠ HttpOnly. One protects transport; the other, reading by JavaScript.
- Secure cookie ≠ authorized user.
- Max Idle Time ≠ Cookie Expiration.
- Session timeouts are not configured in Service Studio.
- Turning on Secure without forcing HTTPS causes session problems.
Full exam map in Security Specialist: what the exam is like and how to study.
Bloquest is independent and not affiliated with OutSystems.