httpd: give the session cookie a Max-Age matching the timeout

The session cookie carried neither Expires nor Max-Age, so browsers that
clean up session cookies aggressively (LibreWolf, for one) may drop it
while the session is still valid. Send Max-Age=session_timeout so the
declared lifetime matches the timeout already enforced by the firmware.

itoa16_html() only converted four digits, so extend it to five to print
timeouts up to 65535. That also fixes information.json, which used the
same helper and reported wrong values from 10000 s up.
This commit is contained in:
gnacho committed 2026-09-16 19:05:48 +02:00
1 parent 6be1871bb4
commit cdc84c75e4
3 files changed
+8 -2

No files matched your search

+2
View File
@@ -668,6 +668,8 @@ static void run_login_body(__xdata uint8_t *body)
"Set-Cookie: session=");
for (uint8_t i = 0; i < SESSION_ID_LENGTH; i++)
outbuf[slen++] = session_id[i];
slen += strtox(outbuf + slen, "; Max-Age=");
itoa16_html(session_timeout);
slen += strtox(outbuf + slen, "; SameSite=Strict\r\n\r\n");
} else {
dbg_string("Password invalid!\n");