CouchbaseLite offline Authentication

What is the recommended approach to be able to let the users login when the device is offline. We authenticate through a custom service that talks to LDAP and create a user and and we get a sessionId back from SyncGateway. This is true when the device is online.

However when the device is offline, if the user tries to login, do you recommend storing the credentials on CBLite or on some other storage? Do we have to tie the each document that gets inserted in CBLite with the sessionId, so that when the device comes online, the records can be pushed to the server?

You can’t log into the server when the device is offline; it doesn’t make any sense. If you want the user to be able to enter their server credentials at any time, even offline, then I suppose you can store the credentials someplace secure (like the Keychain on iOS) so that you can fetch them later on when it’s time to do the actual authentication.

Do we have to tie the each document that gets inserted in CBLite with the sessionId

No. Documents aren’t authenticated. Authentication is only used for the replicator to talk to the server.