Search code examples
sessionparse-platformparse-server

When Parse.com creates a sessionToken and what if this is expired?


In parse dashboard in class _Session, all sessionTokens are being saved. The following actions seem to trigger the creation:

  • Login
  • Sign up
  • Upgrade

The first question is: Is there any other action that will create a new session Token?

And: I see that all token have an expiresAt field. Which is always set 1 year after token createdAt. Can i extent this period (e.g. to 2 years)?

Last: If this token is expired, and a user uses my app, what would happen then? The app will require a new log in (so a new token will be created)?


Solution

  • Correct on the actions.

    Parse-server allows for advance options on initialization. Use sessionLength to set your expiry date.
    If you using environmental variables it will be PARSE_SERVER_SESSION_LENGTH.

    sessionLength - The length of time in seconds that a session should be valid for. Defaults to 31536000 seconds (1 year).

    Depends what you doing client side. You can force log out if the session has expired.

    Also note that when trying to run cloud code with an expired session the following error will show: {"code":209,"message":"Session token is expired."}