What is a Session ID?
A session ID is a unique identifier generated by the Kount SDK that represents a single data collection event. Think of it as a “receipt” that proves device data was collected for a specific user interaction.Session IDs are automatically generated by the SDK. You don’t need to create them manually.
Session ID Format
Session IDs follow a specific format validated by the SDK:- Alphanumeric string (letters and numbers)
- Typically 32 characters long
- Unique for each collection event
- Case-sensitive
Starting with version 4.3.1, the SDK includes improved regex validation and auto-generation for session IDs. If you pass
null or an empty string to collectForSession(), the SDK automatically generates a valid ID.How Session IDs Work
Here’s the complete flow of how session IDs connect your app to Kount’s fraud detection:The Session Workflow
Collection Starts
When you call
collectForSession(), the SDK generates a new session ID and begins collecting device data.Data is Transmitted
The SDK sends the collected device data to Kount’s servers along with the session ID. This happens automatically in the background.
Session ID is Returned
Once collection completes, your success callback receives the session ID. Store this ID—you’ll need it for your backend.
Send to Your Backend
When the user submits a transaction (purchase, signup, etc.), include the session ID in your API request.
Retrieving Session IDs
There are two ways to get the current session ID:Method 1: From the Callback (Recommended)
The most reliable way is to retrieve the session ID from the success callback:Method 2: Query the SDK Directly
You can also query the current session ID at any time:Session Lifecycle
Understanding when sessions begin and end is important:Session Creation
Session Creation
A new session is created every time you call
collectForSession(). Each call generates a new, unique session ID.Session Duration
Session Duration
Sessions don’t expire on the client side. Once created, a session ID remains valid until you create a new one. However, Kount’s servers may have their own time windows for accepting session data.
Consult your Kount integration documentation for server-side session expiration policies.
Multiple Collections
Multiple Collections
You can call
collectForSession() multiple times in your app:- Once per transaction: Most common pattern
- Once per screen: For apps with multiple transaction points
- On-demand: When user performs high-risk actions
Session Persistence
Session Persistence
Session IDs are not persisted across app restarts. If the user closes and reopens your app, you should collect a new session.
Best Practices
One Session Per Transaction
Create a new session for each transaction or user flow. Don’t reuse session IDs across multiple transactions.
Store Session ID Temporarily
Store the session ID in memory (not persistent storage) until your transaction completes.
Handle Collection Failures
Even if collection fails, your app should continue. Let your backend decide whether to proceed based on the risk score.
Include in All Risk Events
Send the session ID for any event that requires fraud assessment:
- Purchases and payments
- Account creation
- Login attempts
- Password changes
- Address updates
- High-value actions
Common Patterns
E-commerce Checkout
Account Registration
Troubleshooting
Session ID is null or empty
Session ID is null or empty
Cause:
getSessionId() was called before any collection occurred.Solution: Always call collectForSession() first, or rely on the callback instead of getSessionId().Backend says session not found
Backend says session not found
Cause: The session ID may not have been transmitted to Kount’s servers yet, or there was a network failure.Solution: Ensure the success callback completes before submitting to your backend. Add retry logic for network failures.
Same session ID for multiple transactions
Same session ID for multiple transactions
Cause: Reusing the same session ID instead of creating a new one.Solution: Call
collectForSession() for each transaction to generate a new session ID.Invalid session ID format
Invalid session ID format
Cause: Manually creating or modifying session IDs (pre-4.3.1 SDK versions).Solution: Always use the session ID provided by the SDK. Upgrade to version 4.3.1+ for improved validation.
Next Steps
Data Collection
Learn what data is collected with each session
Integration Examples
See complete code examples for common scenarios
Backend Integration
Learn how to use session IDs in your backend
API Reference
Explore the complete SDK API documentation
