getSessionToken()
Gets the current session token. Throws an error if the session is not available.
Signature
const token = window.FairShareSDK.getSessionToken();
Returns
string — Session token identifier.
Example
try { const sessionToken = window.FairShareSDK.getSessionToken(); console.log('Session:', sessionToken); } catch (error) { console.error('Session not available:', error.message); }
Error Handling
This method throws if the session token is not available. Common reasons:
initializeFairshare()hasn't been called yet- Session initialization is still in progress
- Session creation failed (check network connectivity)
- Invalid
fluidShopidentifier
Related
- getAttribution — Get attribution data