title: Best practices for creating authentication logic for cross-platform mobile app
body: <p>I am trying to develop a little cross-platform using Xamarin for Visual Studio (2015) which basically reads fields from a SQL Server database and arrange them on a simple UI.  </p>
  
  <p>The database has only got one table, <em>Users</em>, with some columns for user information, plus two of them containing the username and password that the user should utilize to login and see its information.  </p>
  
  <p>I thought of implementing a simple SQL query using the System.Data.SqlClient.SqlConnection class in a similar fashion:  </p>
  
  <pre><code>SELECT TOP 1 *
  FROM Users
  WHERE Username = @username AND Password = @password
  </code></pre>
  
  <p>Or maybe calling a procedure like these<br>
  <a href="https://stackoverflow.com/questions/8895039/easiest-way-to-validate-user-in-stored-procedure">Easiest way to validate user in stored procedure?</a><br>
  with System.Data.SqlClient.SqlCommand</p>
  
  <p>...and then storing, if the login happened, the fields in some variables and then link them to the text boxes on the interface. </p>
  
  <p>I don't know if this is the proper way to do it and it looks like I can't even implement a REST service for the login since there is only one "master" user which can access the database itself.  </p>
  
  <p>The first problem I see with the above logic is how can I check if the user has already logged in, if too much time has passed, without a session or a token?</p>
  
  <p>My question is, does somebody have some good tutorials and guides to study, maybe with some good examples, so I can address this authentication/login difficulty?  </p>
  
  <p>(Sorry for any mistake, I am new to this topic and would like to learn)</p>