Initial commit: 교육 프로젝트 배포

This commit is contained in:
송대일
2026-07-01 18:32:42 +09:00
commit be6dccd120
1483 changed files with 5082202 additions and 0 deletions
+90
View File
@@ -0,0 +1,90 @@
<?php
/**
* 로그아웃 API
* 모든 세션 데이터를 제거하고 쿠키를 삭제합니다.
*/
declare(strict_types=1);
header('Content-Type: application/json; charset=utf-8');
try {
// 세션 시작
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// 로그 기록 (디버깅용)
$logMsg = '[logout.php] Logout requested | Session ID: ' . session_id() . ' | Time: ' . date('Y-m-d H:i:s');
error_log($logMsg);
// 현재 세션 데이터 로그 (디버깅용)
$sessionKeys = implode(', ', array_keys($_SESSION));
error_log('[logout.php] Session keys before clear: ' . ($sessionKeys ?: 'empty'));
// 모든 세션 변수 제거
$_SESSION = [];
// 세션 쿠키 제거
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
$cookiePath = $params['path'] ?: '/';
$cookieDomain = $params['domain'] ?: '';
$cookieSecure = $params['secure'] ?? false;
$cookieHttpOnly = $params['httponly'] ?? true;
// PHP 7.3+ 배열 문법
if (PHP_VERSION_ID >= 70300) {
setcookie(
session_name(),
'',
[
'expires' => 0,
'path' => $cookiePath,
'domain' => $cookieDomain,
'secure' => $cookieSecure,
'httponly' => $cookieHttpOnly,
'samesite' => 'Lax'
]
);
} else {
// PHP 7.2 이하 호환
setcookie(
session_name(),
'',
0,
$cookiePath,
$cookieDomain,
$cookieSecure,
$cookieHttpOnly
);
}
}
// 세션 파괴
@session_destroy();
error_log('[logout.php] Session destroyed successfully');
// 성공 응답
http_response_code(200);
echo json_encode([
'success' => true,
'message' => '로그아웃 되었습니다.',
'timestamp' => date('Y-m-d H:i:s')
], JSON_UNESCAPED_UNICODE);
exit;
} catch (Exception $e) {
error_log('[logout.php] Exception: ' . $e->getMessage());
http_response_code(500);
echo json_encode([
'success' => false,
'message' => '로그아웃 중 오류가 발생했습니다.',
'error' => $e->getMessage()
], JSON_UNESCAPED_UNICODE);
exit;
}