The Session Manager manages user sessions on the server side. It is a persistent Session Manager. It allows to save attributes in the session and retrieve them. This Session Manager is especially useful for Mobile/Device Apps which want to do session management.
In order to use various functions available in a specific API, a developer has to create an instance of ServiceAPI by passing the apiKey and secretKey which will be created after the app creation from AppHQ dashboard.
Required Parameters
apiKey - The Application key given when the application was created.
secretKey - The secret key corresponding to the application key given when the application was created.
ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");ServiceAPI *api = [[ServiceAPI alloc]init]; api.apiKey = @"<API_KEY>"; api.secretKey = @"<SECRET_KEY>";ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");App42.initialize("API_KEY","SECRET_KEY");ServiceAPI api = new ServiceAPI("API_KEY","SECRET_KEY");$api = new ServiceAPI("API_KEY","SECRET_KEY");Coming Soonapi = App42::ServiceAPI.new("<API_KEY>","<SECRET_KEY>")Coming SoonComing Soon
After initialization, developer needs to call the buildXXXService method on ServiceAPI instance to get the instance of the particular API that you wish to build. For example, To build an instance of SessionService, buildSessionService() method needs to be called.
SessionService sessionService = api.buildSessionService();SessionService sessionService = api.BuildSessionService();SessionService *sessionService = [api buildSessionService];SessionService sessionService = api.buildSessionService();SessionService sessionService = api.buildSessionService();SessionService sessionService = api.BuildSessionService();var sessionService = new App42Session();SessionService sessionService = api.BuildSessionService();$sessionService = $api->buildSessionService();Coming Soonsession_service = api.build_session_service()Coming SoonComing Soon
import com.shephertz.app42.paas.sdk.android.ServiceAPI; import com.shephertz.app42.paas.sdk.android.App42Response; import com.shephertz.app42.paas.sdk.android.App42Exception; import com.shephertz.app42.paas.sdk.android.App42BadParameterException; import com.shephertz.app42.paas.sdk.android.App42NotFoundException; import com.shephertz.app42.paas.sdk.android.session.Session; import com.shephertz.app42.paas.sdk.android.session.SessionService;using com.shephertz.app42.paas.sdk.windows; using com.shephertz.app42.paas.sdk.windows.session;#import "Shephertz_App42_iOS_API/Shephertz_App42_iOS_API.h"import com.shephertz.app42.paas.sdk.jme.ServiceAPI; import com.shephertz.app42.paas.sdk.jme.App42Response; import com.shephertz.app42.paas.sdk.jme.App42Exception; import com.shephertz.app42.paas.sdk.jme.App42BadParameterException; import com.shephertz.app42.paas.sdk.jme.App42NotFoundException; import com.shephertz.app42.paas.sdk.jme.session.Session; import com.shephertz.app42.paas.sdk.jme.session.SessionService;import com.shephertz.app42.paas.sdk.java.ServiceAPI; import com.shephertz.app42.paas.sdk.java.App42Response; import com.shephertz.app42.paas.sdk.java.App42Exception; import com.shephertz.app42.paas.sdk.java.App42BadParameterException; import com.shephertz.app42.paas.sdk.java.App42NotFoundException; import com.shephertz.app42.paas.sdk.java.session.Session; import com.shephertz.app42.paas.sdk.java.session.SessionService;using com.shephertz.app42.paas.sdk.csharp; using com.shephertz.app42.paas.sdk.csharp.session;<script type="text/javascript" src="App42-all-x.x.x.min.js"></script>using com.shephertz.app42.paas.sdk.csharp; using com.shephertz.app42.paas.sdk.csharp.session;use com\shephertz\app42\paas\sdk\php\ServiceAPI; use com\shephertz\app42\paas\sdk\php\App42Response; use com\shephertz\app42\paas\sdk\php\App42Exception; use com\shephertz\app42\paas\sdk\php\App42BadParameterException; use com\shephertz\app42\paas\sdk\php\App42NotFoundException; use com\shephertz\app42\paas\sdk\php\session\SessionService; include_once '../ServiceAPI.php'; include_once '../App42Response.php'; include_once '../App42Exception.php'; include_once '../App42BadParameterException.php'; include_once '../App42NotFoundException.php'; include_once '../SessionService.php';Coming Soonrequire 'App42_Ruby_API'Coming SoonComing Soon
Create Session for the User. If the session does not exist it will create a new session.
Required Parameters
userName - Username for which the session has to be created.
String userName = "Nick"; Session session = sessionService.getSession(userName); System.out.println("userName is" + session.getUserName()); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();public class Callback : App42Callback { String userName = "Nick"; sessionService.GetSession(userName, this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { Session session = (Session) response; Console.WriteLine("userName is" + session.GetUserName()); String jsonResponse = session.ToString(); } }NSString *userName = @"Nick"; Session *session = [sessionService getSession:userName]; NSLog(@"User Name is = %@",session.userName); NSLog(@"SessionId is = %@",session.sessionId); NSString *jsonResponse = [session toString];String userName = "Nick"; Session session = sessionService.getSession(userName); System.out.println("userName is" + session.getUserName()); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();String userName = "Nick"; Session session = sessionService.getSession(userName); System.out.println("userName is" + session.getUserName()); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();String userName = "Nick"; sessionService.GetSession(userName, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var userName = "Nick", var session ; sessionService.getSession(userName,{ success: function(object) { var response = JSON.parse(object); session = response.app42.response.session; console.log("userName is " + session.userName) console.log("sessionId is " + session.sessionId) }, error: function(error) { } });String userName = "Nick"; Session session = sessionService.GetSession(userName); Console.WriteLine("userName is" + session.GetUserName()); Console.WriteLine("sessionId is" + session.GetSessionId()); String jsonResponse = session.ToString();$userName = "Nick"; $session = $sessionService->getSession($userName); Print_r("sessionId is" . $session->getSessionId()); Print_r("createdOn is" . $session->getCreatedOn()); $jsonResponse = $session->toString();Coming Soonuser_name = "Nick"; session = session_service.get_session(user_name); puts "userName is #{session.user_name}"; puts "sessionId is #{session.session_id}"; puts "createdOn #{session.created_on}"; json_response = session.to_s();Coming SoonComing Soon
Create User Session based on the isCreate boolean parameter. If isCreate is true and there is an existing session for the user, the existing session is returned. If there is no existing session for the user a new one is created. If isCreate is false and there is an existing session, the existing session is returned if there is no existing session new one is not created.
Required Parameters
userName - Username for which the session has to be created.
isCreate - A boolean value for specifying if an existing session is not there, should a new one is to be created or not.
String userName = "Nick"; boolean isCreate = true; Session session = sessionService.getSession(userName,isCreate); System.out.println("userName is" + session.getUserName()); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();public class Callback : App42Callback { String userName = "Nick"; Boolean isCreate = true; sessionService.GetSession(userName,isCreate, this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { Session session = (Session) response; Console.WriteLine("userName is" + session.GetUserName()); String jsonResponse = session.ToString(); } }NSString *userName = @"Nick"; BOOL isCreate = true; Session *session = [sessionService getSession:userName isCreate:isCreate]; NSLog(@"User Name is = %@",session.userName); NSLog(@"SessionId is = %@",session.sessionId); NSString *jsonResponse = [session toString];String userName = "Nick"; boolean isCreate = true; Session session = sessionService.getSession(userName,isCreate); System.out.println("userName is" + session.getUserName()); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();String userName = "Nick"; boolean isCreate = true; Session session = sessionService.getSession(userName,isCreate); System.out.println("userName is" + session.getUserName()); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();String userName = "Nick"; Boolean isCreate = true; sessionService.GetSession(userName,isCreate, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }Coming SoonString userName = "Nick"; Boolean isCreate = true; Session session = sessionService.GetSession(userName,isCreate); Console.WriteLine("userName is" + session.GetUserName()); Console.WriteLine("sessionId is" + session.GetSessionId()); String jsonResponse = session.ToString();$userName = "Nick"; $isCreate = true; $session = $sessionService->getSession($userName,$isCreate); Print_r("sessionId is" . $session->getSessionId()); Print_r("createdOn is" . $session->getCreatedOn()); $jsonResponse = $session->toString();Coming Soonuser_name = "Nick"; is_create = true; session = session_service.get_session_boolean(user_name, is_create); puts "userName is #{session.userName}"; puts "sessionId is #{session.session_id}"; puts "createdOn #{session.created_on}"; json_response = session.to_s();Coming SoonComing Soon
Invalidate a session based on the session id. All the attributes store in the session will be lost.
Required Parameters
sessionId - The session id for which the session has to be invalidated
String sessionId = "sessionId"; App42Response response = sessionService.invalidate(sessionId); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();public class Callback : App42Callback { String sessionId = "sessionId"; sessionService.Invalidate(sessionId, this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { App42Response user = (App42Response) response; String jsonResponse = user.ToString(); } }NSString *sessionId = @"sessionId"; App42Response *response = [sessionService invalidate:sessionId]; NSString *success = response.isResponseSuccess; NSString *jsonResponse = [response toString];String sessionId = "sessionId"; App42Response response = sessionService.invalidate(sessionId); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();String sessionId = "sessionId"; App42Response response = sessionService.invalidate(sessionId); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();String sessionId = "sessionId"; sessionService.Invalidate(sessionId, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var sessionId = "sessionId", response ; sessionService.invalidate(sessionId,{ success: function(object) { var sessionObj = JSON.parse(object); response = sessionObj.app42.response; console.log("response is " + response) }, error: function(error) { } });String sessionId = "sessionId"; App42Response response = sessionService.Invalidate(sessionId); Boolean success = response.IsResponseSuccess(); String jsonResponse = response.ToString();$sessionId = "sessionId"; $response = $sessionService->invalidate($sessionId); $success = $respons->isResponseSuccess(); $jsonResponse = $respons->toString();Coming Soonsession_id = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; response = session_service.invalidate(session_id); success = response.is_response_success(); json_response = session.to_s();Coming SoonComing Soon
Sets attribute in a session whose session id is provided. Attributes are stored in a key value pair.
Required Parameters
sessionId - Session id for which the attribute has to be saved.
attributeName - The attribute key that needs to be stored.
attributeValue - The attribute value that needs to be stored
String sessionId = "sessionId"; String attributeName = "attributeName"; String attributeValue = "attributeValue"; Session session = sessionService.setAttribute(sessionId,attributeName,attributeValue); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();public class Callback : App42Callback { String sessionId = "sessionId"; String attributeName = "attributeName"; String attributeValue = "attributeValue"; sessionService.SetAttribute(sessionId,attributeName,attributeValue, this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { Session session = (Session) response; Console.WriteLine("sessionId is" + session.GetSessionId()); String jsonResponse = session.ToString(); } }NSString *sessionId = @"sessionId"; NSString *attributeName = @"attributeName"; NSString *attributeValue = @"attributeValue"; Session *session = [sessionService setAttribute:userName attributeName:attributeName attributeValue:attributeValue]; NSLog(@"SessionId is = %@",session.sessionId); NSString *jsonResponse = [session toString];String sessionId = "sessionId"; String attributeName = "attributeName"; String attributeValue = "attributeValue"; Session session = sessionService.setAttribute(sessionId,attributeName,attributeValue); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();String sessionId = "sessionId"; String attributeName = "attributeName"; String attributeValue = "attributeValue"; Session session = sessionService.setAttribute(sessionId,attributeName,attributeValue); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();String sessionId = "sessionId"; String attributeName = "attributeName"; String attributeValue = "attributeValue"; sessionService.SetAttribute(sessionId, attributeName, attributeValue, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var sessionId = "sessionId"; var attributeName = "attributeName"; var attributeValue = "attributeValue"; var session ; sessionService.setAttribute(sessionId,attributeName,attributeValue,{ success: function(object) { var response = JSON.parse(object); session = response.app42.response.session; console.log("sessionId is " + session.sessionId) }, error: function(error) { } });String sessionId = "sessionId"; String attributeName = "attributeName"; String attributeValue = "attributeValue"; Session session = sessionService.SetAttribute(sessionId,attributeName,attributeValue); Console.WriteLine("sessionId is" + session.GetSessionId()); String jsonResponse = session.ToString();$sessionId = "sessionId"; $attributeName = "attributeName"; $attributeValue = "attributeValue"; $session = $sessionService->setAttribute($sessionId,$attributeName,$attributeValue); Print_r("createdOn is" . $session->getCreatedOn()); $jsonResponse = $session->toString();Coming Soonsession_id = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; attribute_name = "attributeName"; attribute_value = "attributeValue"; session = session_service.set_attribute(session_id, attribute_name, attribute_value); puts "sessionId is #{session.session_id}"; attribute_list = Array.new(); attribute_list = session.attribute_list(); for attrbute in attribute_list do puts "name is #{attribute.name}"; puts "attribute is #{attribute.value}"; end json_response = session.to_s();Coming SoonComing Soon
Gets the attribute value in a session whose session id is provided.
Required Parameters
sessionId - The session id for which the attribute has to be fetched.
attributeName - The attribute key that has to be fetched.
String sessionId = "sessionId"; String attributeName = "attributeName"; Session session = sessionService.getAttribute(sessionId,attributeName); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();public class Callback : App42Callback { String sessionId = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; String attributeName = "attributeName"; sessionService.GetAttribute(sessionId,attributeName, this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { Session session = (Session) response; Console.WriteLine("sessionId is" + session.GetSessionId()); String jsonResponse = session.ToString(); } }NSString *sessionId = @"sessionId"; NSString *attributeName = @"attributeName"; Session *session = [sessionService getAttribute:userName attributeName:attributeName]; NSLog(@"SessionId is = %@",session.sessionId); NSString *jsonResponse = [session toString];String sessionId = "sessionId"; String attributeName = "attributeName"; Session session = sessionService.getAttribute(sessionId,attributeName); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();String sessionId = "sessionId"; String attributeName = "attributeName"; Session session = sessionService.getAttribute(sessionId,attributeName); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();String sessionId = "sessionId"; String attributeName = "attributeName"; sessionService.GetAttribute(sessionId, attributeName, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var sessionId = "sessionId"; var attributeName = "attributeName"; var session ; sessionService.getAttribute(sessionId,attributeName,{ success: function(object) { var response = JSON.parse(object); session = response.app42.response.session; console.log("sessionId is " + session.sessionId) }, error: function(error) { } });String sessionId = "sessionId"; String attributeName = "attributeName"; Session session = sessionService.GetAttribute(sessionId,attributeName); Console.WriteLine("sessionId is" + session.GetSessionId()); String jsonResponse = session.ToString();$sessionId = "sessionId"; $attributeName = "attributeName"; $session = $sessionService->getAttribute($sessionId,$attributeName); Print_r("createdOn is" . $session->getCreatedOn()); $jsonResponse = $session->toString();Coming Soonsession_id = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; attribute_name = "attributeName"; session = session_service.get_attribute(session_id, attribute_name); puts "sessionId is #{session.session_id}"; attribute_list = Array.new(); attribute_list = session.attribute_list(); for attribute in attribute_list do puts "name is #{attribute.name}"; puts "attribute is #{attribute.value}"; end json_response = session.to_s();Coming SoonComing Soon
Gets all the attributes for a given session id.
Required Parameters
sessionId - The session id for which the attribute has to be fetched.
String sessionId = "sessionId"; Session session = sessionService.getAllAttributes(sessionId); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();public class Callback : App42Callback { String sessionId = "sessionId"; sessionService.GetAllAttributes(sessionId, this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { Session session = (Session) response; Console.WriteLine("sessionId is" + session.GetSessionId()); String jsonResponse = session.ToString(); } }NSString *sessionId = @"sessionId"; Session *session = [sessionService getAllAttributes:userName]; NSLog(@"SessionId is = %@",session.sessionId); NSString *jsonResponse = [session toString];String sessionId = "sessionId"; Session session = sessionService.getAllAttributes(sessionId); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();String sessionId = "sessionId"; Session session = sessionService.getAllAttributes(sessionId); System.out.println("sessionId is" + session.getSessionId()); String jsonResponse = session.toString();String sessionId = "sessionId"; sessionService.GetAllAttributes(sessionId, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var sessionId = "sessionId"; var session ; sessionService.getAllAttributes(sessionId,{ success: function(object) { var response = JSON.parse(object); session = response.app42.response.session; console.log("sessionId is " + session.sessionId) }, error: function(error) { } });String sessionId = "sessionId"; Session session = sessionService.GetAllAttributes(sessionId); Console.WriteLine("sessionId is" + session.GetSessionId()); String jsonResponse = session.ToString();$sessionId = "sessionId"; $session = $sessionService->getAllAttributes($sessionId); Print_r("createdOn is" . $session->getCreatedOn()); $jsonResponse = $session->toString();Coming Soonsession_id = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; session = session_service.get_all_attribute(session_id); puts "sessionId is #{session.session_id}"; attribute_list = Array.new(); attribute_list = session.attribute_list(); for attribute in attribute_list do puts "name is #{attribute.name}"; puts "attribute is #{attribute.value}"; end json_response = session.to_s();Coming SoonComing Soon
Removes the attribute from a session whose session id is provided.
Required Parameters
sessionId - The session id for which the attributes has to be removed
attributeName - The attribute key that has to be removed
String sessionId = "sessionId"; String attributeName = "attributeName"; App42Response response = sessionService.removeAttribute(sessionId,attributeName); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();public class Callback : App42Callback { String sessionId = "sessionId"; String attributeName = "attributeName"; sessionService.RemoveAttribute(sessionId,attributeName, this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { App42Response user = (App42Response) response; String jsonResponse = user.ToString(); } }NSString *sessionId = @"sessionId"; NSString *attributeName = @"attributeName"; App42Response *response = [sessionService removeAttribute:sessionId attributeName:attributeName]; NSString *success = response.isResponseSuccess; NSString *jsonResponse = [response toString];String sessionId = "sessionId"; String attributeName = "attributeName"; App42Response response = sessionService.removeAttribute(sessionId,attributeName); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();String sessionId = "sessionId"; String attributeName = "attributeName"; App42Response response = sessionService.removeAttribute(sessionId,attributeName); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();String sessionId = "sessionId"; String attributeName = "attributeName"; sessionService.RemoveAttribute(sessionId, attributeName, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var sessionId = "sessionId", attributeName = "attributeName", response ; sessionService.removeAttribute(sessionId,attributeName,{ success: function(object) { var sessionObj = JSON.parse(object); response = sessionObj.app42.response; console.log("response is " + response) }, error: function(error) { } });String sessionId = "sessionId"; String attributeName = "attributeName"; App42Response response = sessionService.RemoveAttribute(sessionId,attributeName); Boolean success = response.IsResponseSuccess(); String jsonResponse = response.ToString();$sessionId = "sessionId"; $attributeName = "attributeName"; $response = $sessionService->removeAttribute($sessionId,$attributeName); $success = $respons->isResponseSuccess(); $jsonResponse = $respons->toString();Coming Soonsession_id = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; attribute_name = "attributeName"; response = session_service.remove_attribute(session_id, attribute_name); success = response.is_response_success(); json_response = session.to_s();Coming SoonComing Soon
Removes all the attributes for a given session id.
Required Parameters
sessionId - The session id for which the attributes has to be removed
String sessionId = "sessionId"; App42Response response = sessionService.removeAllAttributes(sessionId); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();public class Callback : App42Callback { String sessionId = "sessionId"; sessionService.RemoveAllAttributes(sessionId, this); void App42Callback.OnException(App42Exception exception) { Console.WriteLine("Exception Message"); } void App42Callback.OnSuccess(Object response) { App42Response user = (App42Response) response; String jsonResponse = user.ToString(); } }NSString *sessionId = @"sessionId"; App42Response *response = [sessionService removeAllAttributes:sessionId]; NSString *success = response.isResponseSuccess; NSString *jsonResponse = [response toString];String sessionId = "sessionId"; App42Response response = sessionService.removeAllAttributes(sessionId); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();String sessionId = "sessionId"; App42Response response = sessionService.removeAllAttributes(sessionId); boolean success = response.isResponseSuccess(); String jsonResponse = response.toString();String sessionId = "sessionId"; sessionService.RemoveAllAttributes(sessionId, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { App42Log.Console("Success : " + response); } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }var sessionId = "sessionId", response ; sessionService.removeAllAttributes(sessionId,{ success: function(object) { var sessionObj = JSON.parse(object); response = sessionObj.app42.response; console.log("response is " + response) }, error: function(error) { } });String sessionId = "sessionId"; App42Response response = sessionService.RemoveAllAttributes(sessionId); Boolean success = response.IsResponseSuccess(); String jsonResponse = response.ToString();$sessionId = "sessionId"; $response = $sessionService->removeAllAttributes($sessionId); $success = $respons->isResponseSuccess(); $jsonResponse = $respons->toString();Coming Soonsession_id = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; response = session_service.remove_all_attribute(session_id); success = response.is_response_success(); json_response = session.to_s();Coming SoonComing Soon
The functions available under Session Management API can throw some exceptions in abnormal conditions. Example of the same has been given below. E.g. If App developer is trying to invalidate a Session which is already in invalidated, the function will throw the App42Exception (as shown below) with message as “Not Found” and the appErrorCode as “2202” and the details as “Session with the id ‘48dacb76-7f5e-4011-ac24-e09623bdc70f’ does not exist”.
String sessionId = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; try { App42Response response = sessionService.invalidate(sessionId); } catch(App42Exception ex) { int appErrorCode = ex.getAppErrorCode(); int httpErrorCode = ex.getHttpErrorCode(); if(appErrorCode == 2202) { // Handle here for Not Found (Session with the id '@sessionId' does not exist.) } else if(appErrorCode == 2203) { // Handle here for Bad Request (The request parameters are invalid. Session with the Id '@sessionId' is already invalidated.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = ex.getMessage(); }public class Callback : App42Callback { String sessionId = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; sessionService.Invalidate(sessionId, this); void App42Callback.OnException(App42Exception exception) { int appErrorCode = exception.GetAppErrorCode(); int httpErrorCode = exception.GetHttpErrorCode(); if(appErrorCode == 2202) { // Handle here for Not Found (Session with the id '@sessionId' does not exist.) } else if(appErrorCode == 2203) { // Handle here for Bad Request (The request parameters are invalid. Session with the Id '@sessionId' is already invalidated.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = exception.GetMessage(); } void App42Callback.OnSuccess(Object response) { Session session = (Session) response; String jsonResponse = session.ToString(); } }NSString *sessionId = @"48dacb76-7f5e-4011-ac24-e09623bdc70f"; @try { App42Response *response = [sessionService invalidate:sessionId]; } @catch(App42Exception *ex) { int appErrorCode = ex.appErrorCode; int httpErrorCode = ex.httpErrorCode; if(appErrorCode == 2202) { // Handle here for Not Found (Session with the id '@sessionId' does not exist.) } else if(appErrorCode == 2203){ // Handle here for Bad Request (The request parameters are invalid. Session with the Id '@sessionId' is already invalidated.) } else if(appErrorCode == 1401){ // handle here for Client is not authorized } else if(appErrorCode == 1500){ // handle here for Internal Server Error } NSString *jsonText = ex.reason; }String sessionId = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; try { App42Response response = sessionService.invalidate(sessionId); } catch(App42Exception ex) { int appErrorCode = ex.getAppErrorCode(); int httpErrorCode = ex.getHttpErrorCode(); if(appErrorCode == 2202) { // Handle here for Not Found (Session with the id '@sessionId' does not exist.) } else if(appErrorCode == 2203) { // Handle here for Bad Request (The request parameters are invalid. Session with the Id '@sessionId' is already invalidated.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = ex.getMessage(); }String sessionId = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; try { App42Response response = sessionService.invalidate(sessionId); } catch(App42Exception ex) { int appErrorCode = ex.getAppErrorCode(); int httpErrorCode = ex.getHttpErrorCode(); if(appErrorCode == 2202) { // Handle here for Not Found (Session with the id '@sessionId' does not exist.) } else if(appErrorCode == 2203) { // Handle here for Bad Request (The request parameters are invalid. Session with the Id '@sessionId' is already invalidated.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = ex.getMessage(); }Coming Soonvar sessionId = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; var appErrorCode ; sessionService.invalidate(sessionId,{ success: function(object) { }, error: function(error) { var sessionObj = JSON.parse(error); appErrorCode = sessionObj.app42Fault.appErrorCode; if(appErrorCode == 2202) { // Handle here for Not Found (Session with the id '@sessionId' does not exist.) } else if(appErrorCode == 2203) { // Handle here for Bad Request (The request parameters are invalid. Session with the Id '@sessionId' is already invalidated.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } } });String sessionId = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; try { App42Response response = sessionService.Invalidate(sessionId); } catch(App42Exception ex) { int appErrorCode = ex.GetAppErrorCode(); int httpErrorCode = ex.GetHttpErrorCode(); if(appErrorCode == 2202) { // Handle here for Not Found (Session with the id '@sessionId' does not exist.) } else if(appErrorCode == 2203) { // Handle here for Bad Request (The request parameters are invalid. Session with the Id '@sessionId' is already invalidated.) } else if(appErrorCode == 1401) { // handle here for Client is not authorized } else if(appErrorCode == 1500) { // handle here for Internal Server Error } String jsonText = ex.GetMessage(); }$sessionId = "48dacb76-7f5e-4011-ac24-e09623bdc70f"; try { $response = $sessionService->invalidate($sessionId); } catch(App42Exception $ex) { $appErrorCode = $ex->getAppErrorCode(); $httpErrorCode = $ex->getHttpErrorCode(); if($appErrorCode == 2202) { // Handle here for Not Found (Session with the id '@sessionId' does not exist.) } else if($appErrorCode == 2203){ // Handle here for Bad Request (The request parameters are invalid. Session with the Id '@sessionId' is already invalidated.) } else if($appErrorCode == 1401){ // handle here for Client is not authorized } else if($appErrorCode == 1500){ // handle here for Internal Server Error } $jsonText = $ex->getMessage(); }Coming SoonComing SoonComing SoonComing Soon
Functions in Session API might throw exceptions with following HTTP and Application Error Codes (along with their descriptions):
1400 - BAD REQUEST - The Request parameters are invalid
1401 - UNAUTHORIZED - Client is not authorized
1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again
2200 - NOT FOUND - User by the name '@userName' does not exist.
2201 - NOT FOUND - Session for the user '@userName' does not exist.
2202 - NOT FOUND - Session with the id '@sessionId' does not exist.
2203 - BAD REQUEST - The request parameters are invalid. Session with the Id '@sessionId' is already invalidated.
2204 - NOT FOUND - Attribute with the name '@name' for session id '@sessionId' does not exist.
2205 - NOT FOUND - There are no attributes for session id '@sessionId'.
2206 - NOT FOUND - Attributes for session id '@sessionId' do not exist.