<?php
if (session_status() === PHP_SESSION_NONE) session_start();
function isMobile() {
    $ua = strtolower($_SERVER['HTTP_USER_AGENT'] ?? '');
    foreach(['mobile','android','iphone','ipad','ipod','blackberry','windows phone'] as $kw)
        if(str_contains($ua,$kw)) return true;
    return false;
}
if (isset($_SESSION['user_id'])) {
    header('Location: ' . (isMobile() ? '/cash_lending/mobile/dashboard.php' : '/cash_lending/dashboard.php'));
} else {
    header('Location: /cash_lending/login.php');
}
exit();
