$server, 'username' => $username, 'password' => $password, 'db' => $database, ]; $_SESSION['token'] ??= bin2hex(random_bytes(16)); // If accessed directly, redirect to auto-login if (isset($_GET['auto'])) { // Auto-login by setting the auth cookie $auth_json = json_encode($auth); setcookie('adminer', base64_encode($auth_json), time() + 3600, '/', '', $_SERVER['HTTPS'] ?? false); header('Location: ?server=' . urlencode($server) . '&username=' . urlencode($username) . '&db=' . urlencode($database)); exit; }