<?php
session_set_cookie_params([
  'lifetime' => 0,
  'path'     => '/',
  'domain'   => '.sociallinkscraper.com',
  'secure'   => true,
  'httponly' => true,
  'samesite' => 'None'
]);
session_start();

header('Content-Type: application/json');

if (!empty($_SESSION['user_id'])) {
    echo json_encode([
      'authenticated' => true,
      'name'          => $_SESSION['name']       ?? '',
      'email'         => $_SESSION['email']      ?? '',
      'phone'         => $_SESSION['phone']      ?? '',
      'plan'          => $_SESSION['plan']       ?? '',
      'expires_at'    => $_SESSION['expires_at'] ?? '',
    ]);
} else {
    echo json_encode(['authenticated' => false]);
}
exit;
