Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

JSON If Statements Question

I'm in the process of building a login system for my application which makes a JSON request to a server from the app with a username and password and then it acts upon the result (also in JSON). If the login was successful, the JSON element called status returns success, and if not, it returns as a failure. I'm working with this code to process the login:

loginstatus = JSON.parse(this.responseText).status;

Then, I'm trying to act upon the loginstatus variable to determine if the app should let the user in. For that, I have the code below. My question is: is that the proper way to do that below? If the returned JSON is parsed above, will the code below work if the returned element equals success?

    if(loginstatus == "success") {

    // code to let the user in to the app

Thanks for your help.

— asked August 11th 2010 by Grant Derderian
  • json
  • mobile
  • parsing

1 Answer

  • Accepted Answer


    I think it should work, but I suggest you to generate a sessionId on login and your phone program should send this sessionId on every call to the server. Your server should check the session validity on every call.

    Another thing is that you should use https connection or you should encrypt passwords before sending to your server.

    If it is a service, you also should disable access after some failure of logins (maybe 3 times). Without it anybody can use some bruteforce program to get access to your server.

    — answered August 12th 2010 by Adam Wallner
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.