Session Decoder

The Session Decoder is a client-side javascript that extracts the userId from the FTSession_s cookie, without making a remote API call to the Session API. This utility method is useful in scenarios where you are interested in obtaining the userId from a session cookie without knowing if the session is still valid.

Javascript source URL

https://sessionapi.memb.ft.com/static/js/session-decoder-bundle.min.js

Usage

  1. Include the session decoder javascript in your page:

  1. To extract the userId from the FTSession_s cookie:

var sessionDecoder = new SessionDecoder(‘publicKey’);

var userId = sessionDecoder.extractUuidFromSession(); 

Where:

publicKey - used to verify the session token signature derived from the FTSession_s cookie. Please email: FT Membership Platform Team to obtain the public key.

Success Response

Extracted FT userId will be returned.

Error Response

Error Message Reason
Missing public key No public key supplied when instantiating SessionDecoder
Missing FTSession_s cookie No FTSession_s cookie found, thus the user hasn’t logged in.
Invalid session - incorrect format The format of the FTSession_s cookie value is invalid.
Signature Verification failed Either incorrect public key provided or the session token from FTSession_s is invalid