Log off when logging in

2

Good morning everyone! Gentlemen, I need guidance and I also need to know if I can do it. It is the following: I have a table in my database that registers the users that are logged in, it follows:

What I want to do is, every time a login is made (besides the normal login routine) it is checked in this table whether the face is logged in or not. If it is logged in, I want to compare the sessions that are in the database and the one I will get at the time of login, and update the session, date and ip. If the comparison is wrong, I want to update the new information, and the session that was there was destroyed.

Can you do this? Thank you!

    
asked by anonymous 11.11.2015 / 13:52

2 answers

0
  • Select the record by the login field.
  • Compare if the sc_session field is equal to session_id ()
  • If it is not the same, delete the previously selected record or update with the current data
  • 11.11.2015 / 14:16
    0

    When logged in, delete that user's login records, or if you prefer, place a column that identifies that situation. Put a validation right after the session is started (session_start) makes a select to check if the session_id is in the table, if it is not, use session_destroy to end this session.

        
    11.11.2015 / 15:34