PelcroUserLogout
Fired when user logs out
Overview
Fired when a user logs out, either explicitly via logout() or when a session becomes invalid.
Triggered By
| Method | Description |
|---|---|
Pelcro.user.logout() | Explicit logout |
| Session invalidation | When auth token becomes invalid (401/403 response) |
Event Detail
The event.detail object contains the auth state at logout:
| Property | Type | Description |
|---|---|---|
token | string | null | The invalidated auth token |
Example
document.addEventListener('PelcroUserLogout', (event) => {
console.log('User logged out');
// Clear user-specific UI
clearUserDisplay();
// Reset premium content access
hidePremiumContent();
// Track logout in analytics
analytics.track('User Logged Out');
// Redirect to home page
window.location.href = '/';
});Session Invalidation
This event also fires when the SDK detects an invalid session during a refresh() call. This happens when:
- The auth token has expired
- The token was revoked server-side
- The user logged in on another device (if single-session is enforced)
Related
- Events Overview - All available events
- PelcroUserLoggedIn - Login event
- User Module - Logout method
Updated 1 day ago
