curl -X GET https://api.demet.com/intern/logout \
-b cookies.txt \
-c cookies.txt
{
"message": "Sesión cerrada"
}
End the current session and clear authentication cookies
curl -X GET https://api.demet.com/intern/logout \
-b cookies.txt \
-c cookies.txt
{
"message": "Sesión cerrada"
}
access_token and refresh_token cookies, effectively logging out the user and ending their session.
curl -X GET https://api.demet.com/intern/logout \
-b cookies.txt \
-c cookies.txt
{
"message": "Sesión cerrada"
}
access_token cookierefresh_token cookieShow Cleared Cookies
| Cookie Name | Description |
|---|---|
access_token | JWT token used for API authentication |
refresh_token | JWT token used for refreshing access tokens |
res.clearCookie() method, which sets their expiration date to the past.async function logout() {
try {
// Call the logout endpoint
const response = await fetch('https://api.demet.com/intern/logout', {
method: 'GET',
credentials: 'include'
});
const data = await response.json();
console.log(data.message); // "Sesión cerrada"
// Clear any local user data
localStorage.removeItem('user');
sessionStorage.clear();
// Redirect to login page
window.location.href = '/login';
} catch (error) {
console.error('Logout error:', error);
// Still clear local data and redirect
localStorage.removeItem('user');
window.location.href = '/login';
}
}