Guide to managing authentication sessions in Para for Swift applications
Para Swift SDK provides robust session management, automatically tracking authentication states and ensuring secure, seamless interactions. Effective session management is critical for security, usability, and reliability of your application.
Para manages sessions using the ParaSessionState
enum:
unknown
: Initial state before the status is determined.inactive
: SDK initialized but no active session.active
: Session is active but user not fully logged in.activeLoggedIn
: User is fully logged in with an active session.Utilize SwiftUIโs Combine or other state management tools to observe changes:
The Para session length is 2 hours
by default, but can be configured to up to 30 days. To configure this parameter, please visit the Configuration section of the Developer Portal. A user signing a message or transaction extends the session by the duration of the session length.
isSessionActive() async throws -> Bool
: Checks if the session is currently valid before performing authenticated operations.isFullyLoggedIn() async throws -> Bool
: Checks if the user is fully logged in with an active session.exportSession() async throws -> String
: Exports session state as a string that can be used for advanced integration scenarios.logout() async throws
: Clears the current session, removes all website data from the WebView, and resets the session state to inactive.For long-running applications, check session status before performing sensitive operations:
When a session has expired, Para recommends initiating a full authentication flow rather than trying to refresh the session.
For Swift applications, always call logout()
before reinitiating authentication when a session has expired to ensure all stored data is properly cleared.
Clear sensitive data when app goes to background by logging out:
In some advanced scenarios, you may need to export the session state:
Verify session status when your app starts to determine if users need to reauthenticate:
Swift apps can be backgrounded and foregrounded, which may affect session status:
Explore more advanced features and integrations with Para in Swift:
Guide to managing authentication sessions in Para for Swift applications
Para Swift SDK provides robust session management, automatically tracking authentication states and ensuring secure, seamless interactions. Effective session management is critical for security, usability, and reliability of your application.
Para manages sessions using the ParaSessionState
enum:
unknown
: Initial state before the status is determined.inactive
: SDK initialized but no active session.active
: Session is active but user not fully logged in.activeLoggedIn
: User is fully logged in with an active session.Utilize SwiftUIโs Combine or other state management tools to observe changes:
The Para session length is 2 hours
by default, but can be configured to up to 30 days. To configure this parameter, please visit the Configuration section of the Developer Portal. A user signing a message or transaction extends the session by the duration of the session length.
isSessionActive() async throws -> Bool
: Checks if the session is currently valid before performing authenticated operations.isFullyLoggedIn() async throws -> Bool
: Checks if the user is fully logged in with an active session.exportSession() async throws -> String
: Exports session state as a string that can be used for advanced integration scenarios.logout() async throws
: Clears the current session, removes all website data from the WebView, and resets the session state to inactive.For long-running applications, check session status before performing sensitive operations:
When a session has expired, Para recommends initiating a full authentication flow rather than trying to refresh the session.
For Swift applications, always call logout()
before reinitiating authentication when a session has expired to ensure all stored data is properly cleared.
Clear sensitive data when app goes to background by logging out:
In some advanced scenarios, you may need to export the session state:
Verify session status when your app starts to determine if users need to reauthenticate:
Swift apps can be backgrounded and foregrounded, which may affect session status:
Explore more advanced features and integrations with Para in Swift: