<?php
if (session_status() === PHP_SESSION_NONE) { session_start(); }
require_once '../../config.php';
header('Content-Type: application/json');

if (isset($_SESSION['verify_email'])) {
    $email = $_SESSION['verify_email'];
    $stmt = $conn->prepare("SELECT is_verified FROM users WHERE email=?");
    $stmt->bind_param("s", $email);
    $stmt->execute();
    $res = $stmt->get_result();
    
    if ($res->num_rows > 0) {
        $row = $res->fetch_assoc();
        if ($row['is_verified'] == 1) {
            unset($_SESSION['verify_email']); // ভেরিফাই হলে সেশন ক্লিয়ার
            echo json_encode(['status' => 'verified']);
            exit();
        }
    }
}
echo json_encode(['status' => 'pending']);
?>