i have a question.
I have a website in which i am giving security like login id and password( as usual). No what i want is that,
1) I don’t want to allow a single user to login in different machine at the same time.
2) For this i am using a column in database which is keeping the current status of user(i.e. loging/logout). I am allowing user to login only when has session has not closed and status is login.
3) So my problem is that when i am logging out manually. it is closing the session as well as updating the database with status “logout”.
4) but when i am closing the window from Cross buttonat top right corner. it is closing the ssion but table data is still “login”. so later on i can’t be able to login into the same user.
5) So how could i solve this problem.
Please help me!
i have a question. I have a website in which i am giving security
Share
Every time a user tries to login, check if a session has already been set. You can do this by saving a hash of a unix time stamp to the database that is associated with the user as well as set the hash to the session every time a user logins. Once the user logins again, you’ll create a new hash which will overwrite the old hash in the database.
Then in all your protected files, you can compare the session hash variable to the one in the database. If it doesn’t match, log the user out- but the new login instance will still stay active.
For this, you have to save a last active unix time stamp. You will also have to come up with amount of time before you “logout” the user- this is usually an hour or 3600 seconds. Either using a cron job or an include file on certain pages, you can check the times for the users and compare them doing
if(time - last_active_time > 3600){your_logout_func();}5) So how could i solve this problem. Please help me!
Doing that above should fix your problems, but of course there are many ways to solve it 🙂