Whats the point of "sessionService.getSession"

0 votes
Hello Shephertz,

Im having a hard time to see the point of getSession API, this function needs (sessionId and username) but if I already have these parameters, whats the pointing of calling this function? isnt sessionId unique for every session and user?

lets say I want to authenticate the user automatically, after the first login, cant I just store username and password on the local database(e.g. in Playerprefs in case of unity3d), retreive them after the next startup of the app, and autheticate the user?

As far as I can see sessionId and loggedInUser also get saved in Playerprefs.

thanks
asked Aug 13, 2015 in App42 Cloud API-BaaS by armin65 (39 points)

1 Answer

+2 votes
 
Best answer

Hello Armin,

GetSession API of SessionService only asks for userName as parameter. Please go through our documentation and let me know if you have further queries.

Thanks.

answered Aug 13, 2015 by rajeev.etc (1,660 points)
selected Aug 14, 2015 by armin65
Oh you are right, so am i correct to suppose the following; to implement an autologin feature, I have to save the sessionId on the local database and with the next app-start compare it with the sessionId that this function gives me?
It is not needed. You just have to save the userName in your local database and use GetSession(http://api.shephertz.com/app42-docs/session-management-service/?sdk=unity#get-session-create) API to get the session from cloud. GetSesion API will take userName and isCreate as parameter. Pass false as a value for isCreate parameter. In this way, if there is a valid session for the user on cloud then this will return sessionID and if there is no valid session then it will return you an App42Exception. Please check the above link for more details.
Thanks so much for the clarification, one last thing and Ill be on my way, Can I just rely on Installation.GetLoggedInUser() to get the username, as far as I can see the Installation class uses Playerprefs and it would be a waste to implement something new.
Yeah, there is no need to store userName if you are doing App42API.SetLoggedInUser(userName) then you can fetch the same using App42API.GetLoggedInUser(). Let me know if you further queries.
Hi,

where are Installation.GetLoggedInUser or App42API.SetLoggedInUser documented ? Can't find any reference.
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
...