http://qs321.pair.com?node_id=412633


in reply to delete users

Hi.

This looks as a flat text file to me, so I don't know if I exactly understood your question, but I really wanna help you, so let's start.

If you were just representing a database, this would be easy, just do a simple SQL query:

DELETE FROM your_table_name WHERE USERNAME = 'desired_user';

If I was right at the first time and you just use a flat text file, take a look at Deleting a line out of text file for a start. That sould guide you fine.

For your second question the answer is a little bit longer:

Since your developing a system that has a web interface, a problem arise:

What if the user just close the browser (by pressing ALT F4 or just clicking on that dreaded top right 'X' ;))? Since it's a hard thing to trigger an event when the user does this (I won't expand too much here since this is more a JavaScript thing) the user session (assuming that there is one) would remain opened and this is a security breach.

So, the solution I've found out (and IMHO is the most used out there) is to do the following:

  1. When the user logs in store his session id and the current date and time on the database (or flat file).
  2. Each and every page entered by the user should do a check if the user data exists and update the database updating the date and time.
  3. Run a cron job that checks every XX minutes if the date and time of the user session is active and if is not (his date and time are over the XX minutes interval) delete his data from the db. So, the next page will see that the user data doesn't exist anymore and will redirect the user to (probably) the login page, so he starts the process all over again.


Your logout routine (for the logout link) should just destroy the user session and delete his data from the database.

There are a lot of issues on this question, but I hope I helped a little. Feel free to contact me if you have any questions.

Best regards,