Last active
February 6, 2017 10:48
-
-
Save soulfly/7dc288748c25e9df8de96d021b610ac9 to your computer and use it in GitHub Desktop.
validate session token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String token = BaseService.getBaseService().getToken(); | |
Date expirationDate = BaseService.getBaseService().getTokenExpirationDate(); | |
// save to secure storage when your application goes offline or to the background | |
... | |
// recreate session on next start app | |
Date currentDate = new Date(); | |
Calendar cal = Calendar.getInstance(); | |
cal.setTime(currentDate); | |
cal.add(Calendar.HOUR, 2); | |
Date twoHoursAfter = cal.getTime(); | |
if(expirationDate.before(twoHoursAfter)){ | |
// valid token | |
}else{ | |
// create a session | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment