A McGraw Hill Book Plug-in PHP: 100 Power Solutions
By Robin Nixon (McGraw Hill 2010, ISBN 978-0071666596)

Home | About | Buy It | Download | Contact

Select Chapter: 1  2  3  4  5  6  7  8  9 10 11 12

Chapter 9: Plug-in 70 - Block User By Cookie

If you've ever done any chat related programming you'll have come across trolls and just plain nasty individuals who you don't want on your site. You may even have banned them by their IP address. If you have, you may also have encountered the problem of these individuals restarting their web connections to obtain new IP addresses with which to harass you and your users. You will also possibly have noticed that some 'bad' users share their IP address with 'good' ones, generally because they work in the same building and share a DSL or similar Internet connection. So blocking a 'bad' user by IP would also block 'good' ones. But there is a way you can ban unwanted users more permanently and precisely, and that's to leave a cookie on their computer, as this plug-in does.

The Figure shows a session being opened with the PIPHP_OpenSession() plug-in, and then this plug-in, PIPHP_BlockUserByCookie(), being called to send a blocking cookie to the user's browser.