<?php
declare(strict_types=1);

namespace App\Controllers;

use App\Core\Controller;

final class WhoAmIController extends Controller
{
    public function index(): void
    {
        header('Content-Type: text/plain; charset=utf-8');
        if (session_status() !== PHP_SESSION_ACTIVE) session_start();
        echo "uid=".(int)($_SESSION['user_id'] ?? 0)."\n";
        echo "role=".(function_exists('auth_role_code') ? auth_role_code() : 'NO')."\n";
        echo "cookie_path=".ini_get('session.cookie_path')."\n";
        echo "script_name=".($_SERVER['SCRIPT_NAME'] ?? '')."\n";
        echo "request_uri=".($_SERVER['REQUEST_URI'] ?? '')."\n";
    }
}
