PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I got another question. Can I make PHP do something after the user closes him/her browser? My site runs on sessions and I want php to delete a row from a database after a user "logs off" from my site.
I think you just have to wait for the session to time out...not positive though...but as far as I know, since PHP is server side it doesn't really have any way of knowing that the client has closed their browser and therefor can't do anything about it.
php.ini file will do that. You can set it to stop using the session to any interval you like. It will not purge it from your database however.
One thing you can do is have an insert at the top of each page to purge any row thats session time is greater than the specified time. I use this for a usersonline script. When the page is loaded it purges any entry that is more than 6 minutes old.
set a timestamp when you start's a session and update the timestamp when the user do something.. and delete the session if timestamp is more than 30min old..
You can add onClose javascript that will open small window with php file in it. You can do anything you want and than send small javascript that will close the window. You need to do that fast, without anoying visitor. It will not work with some popup stopers or javascript disabled browsers.