Banning a user with cookies

Hi!

I need some help.

Can anyone tell me how I would go about coding a PHP system in which I can give a user a cookie (if they register, etc.), and the system checks if that cookie exists. If it does, the system displays a ban message. I would also like to know if it is possible to check for the cookie, and if it exists, also ban by IP. Or, if a user has a certain banned IP give them a ban cookie too.

I hope I didn’t make it too confusing to understand, but if anyone can help me I would appreciate it.