public JsonResult <String> Post(int id, int loginYN, [FromBody] FormDataCollection sessionVar) { int validKlant = 0; String strSessionId = ""; String strSessionToken = ""; if (loginYN == 0) // Logout is ok { this.sessApi.sessionClear(); strSessionId = this.sessApi.sessionGetId(); this.sessdao.deleteSession(new SessionLocation(id, "", "")); } else // Login { // Id is not possible try { validKlant = klantdao.isValidKlant(new Klant(0, "", sessionVar.GetValues("pwd")[0], sessionVar.GetValues("email")[0]) ); } catch (NullReferenceException ee) { validKlant = 0; } if (validKlant != 0) // If klant is valid { // First delete old session vars from klant... try { this.sessdao.deleteSession(new SessionLocation( validKlant, "", "" )); } catch (Exception ee) { } // Create new session... strSessionId = sessApi.sessionGetId(); strSessionToken = Encrypt.EncryptString(strSessionId, ""); // Encrypt the sessionId for token //this.sessApi.sessionAdd(this.SESSIONUSRID, id.ToString()); //this.sessApi.sessionAdd(this.SESSIONTOKEN, strSessionToken); // Save to the session try { this.sessdao.saveSession(new SessionLocation(validKlant, strSessionId, strSessionToken)); // new SessionLocation(id, "Blala", "Blala")); } catch (Exception ee) { strSessionId = ee.ToString(); } } } return(Json("[{ \"klantid\" :\" " + validKlant + "\" , \"sessionid\" :\" " + strSessionId + "\" , \"sessiontoken\": \"" + strSessionToken + "\"}]")); // Empty Json }