mirror of
git://f0xx.org/ac/ac-platform-php
synced 2026-07-29 02:18:27 +03:00
Secure session cookies behind TLS-terminating FE. resolve_console_route recognizes /two-factor/approve and /api/two-factor/poll. Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
779 B
PHP
25 lines
779 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Shared session for all Android Cast web consoles (crashes, build, …).
|
|
* Same cookie path + session name => one login across sub-apps.
|
|
*/
|
|
function platform_start_session(string $sessionName = 'ac_crash_sess', string $cookiePath = '/app/androidcast_project'): void
|
|
{
|
|
if (session_status() === PHP_SESSION_ACTIVE) {
|
|
return;
|
|
}
|
|
session_name($sessionName);
|
|
$secure = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')
|
|
|| strtolower((string) ($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '')) === 'https';
|
|
session_set_cookie_params([
|
|
'lifetime' => 0,
|
|
'path' => $cookiePath,
|
|
'httponly' => true,
|
|
'samesite' => 'Lax',
|
|
'secure' => $secure,
|
|
]);
|
|
session_start();
|
|
}
|