Keep user logged in after app is closed

0 votes

I want it so the user does not have to keep signing in everytime the app is started. How would I go about this?

This is what I have so far 

using System.Collections.Generic;
using System.Net;
using System;
using com.shephertz.app42.paas.sdk.csharp;
using com.shephertz.app42.paas.sdk.csharp.session;
using AssemblyCSharp;
 
public class LoadMenuOrLogin : MonoBehaviour {
 
ServiceAPI sp = null;
SessionService sessionService = null; // Initializing User Service.
SessionResponse callBack = new SessionResponse();
 
public string SavedSession;
 
// Use this for initialization
void Start () {
SavedSession = PlayerPrefs.GetString ("SessionID");
}
 
// Update is called once per frame
void Update () {
 
 
if (SavedSession == null)
{
Application.LoadLevel("LogIn"); 
}
else 
{
Application.LoadLevel("menu");
}
 
}
}
asked Jul 3, 2014 in App42 Cloud API-BaaS by rnvitter (22 points)

1 Answer

0 votes

Hi,

Thanks for writing to us.

You can easily achieve this by maintaining the sessionId of that user in app local data base.

When the user login into app for the first time, you will get the sessionId of that user in the result of authenticate call .

You can save that sessionId in app local database & when the user again starts the app, you can verify the sessionId of that user is validated or not.

If the sessionId is valid, Let the user enter without asking for credentials again else redirect him to login page.

Let me know if it helps.

Thanks.

answered Jul 4, 2014 by hs00105 (517 points)
1. how to verify the sessionId of that user is validated or not ???
2. When I call Session sessiontmp = mSessionService.GetSession (username, false); I get the error: "Client is not authorized to create session".
but I have authorized my username.
I enabled app acl.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...