The SessionID can be used to handle security from the database, even though there is several ways to implement securiry, this is a simple and safe way to do it.
Session Table
Create a table with the name ActiveSessions and the column SessionID as the primary key, and UserID as a nullable field. If the UserID has a value, it indicates that the user is logged in. You may also add more values, like CreatedWhen, LoggedinWhen etc.
Login
Check the username and password, and update the Session table with the UserID.
Logout
Update the Session table, and set the UserID to null. You can also delete the row.
Security check
In the top of the main stored procedure, you can add these two lines:
DECLARE @UserID as Int
SELECT @UserID=UserID FROM ActiveSessions WHERE SessionID=@SessionID
If @UserID is not null, the User is logged in.
Last updated: 15 oct 2015
Give us feedback
AngularJS <-> Microsoft SQL
Exchange data between your AngularJS application and your Microsoft SQL Server