Reputation:
I am working on an application that allows users to have a profil ...
For security reasons, i want to deny connexion to already connect user, which means if a user is connected from a machine, he can't connect from another one, some people may say cookies and sessions but i'm using an "Application" not a website.
for now, i added a column is the users table in my database called "IsConnected" so before logging in, the Application check if this column is set at 1 or 0 and based on this value allow or deny connexion to this user, it is working, but not perfectly. if the user close the application without disconnecting the column is not set to 0 so the user is always connected.
my hope is that you guys tell me another way for doing thing, because am new to this domain and i need your help.
Upvotes: 1
Views: 358
Reputation: 2017
I doubt there is any cookies for desktop application, it was made to keep some data in browser, you can keep any data in your application without it.
In database you can store date and time of last user activity along with some device identifier, like maybe mac address. Connected application should refresh that information, for example every hour, and if user was connected two or more hours ago, he is disconnected and can connect again from different device. He should be able to disconnect explicitly too, but in case application crashed or pc rebooted or who knows what happened it has to disconnect users, which haven't done server activity for some time.
Upvotes: 1