I am working on an application that requires users to log in before they can use it. Users should only be able to log in when connected to the internet. When a user logs in, a token should be stored on the device, allowing for offline use of the application without logging in again. I basically want to check if this token is present and take the user to the application if it is or the login screen otherwise. Additionally this token should expire after a while.
The question is if there is a way to store a token, that will expire after, let's say, 24 hours, without the user being able to tamper with it or trick the system in any way (e.g. if the token is timestamped and the user changes the device time). The token should expire without the user being connected to the internet, so that the user won't be able to use the application forever without reauthenticating every once in a while.
I've not been able to find an answer to this question although it seems simple enough. I've looked into technologies such as OAuth and NSHTTPCookie, but these seem concerned with online authentication whereas I am trying to authenticate the user in an offline setting.