Jump to content

stopping posts floods and cookies


turkman

Recommended Posts

i dont understand whats going on. This always worked before... everytime someone makes a post i set a cookie

 

setcookie("Postflood",$ip,time()+POST_FLOOD);

 

post_flood is declared in globals as 30 - i.e 30 seconds between posts.

 

then when you go to make another post it does an isset($_COOKIE['postflood'])

 

even under 30 seconds it still doesnt see the cookie as having been set.... im not sure why this doesnt work?

Link to comment
Share on other sites

Cookies are in the hands of the visitor (or bot script) that is posting on your site. You cannot rely on the existence or absence of a cookie or the value in a cookie for the purpose you are attempting because a cookie can be deleted or altered and most simple bot scripts don't even accept cookies so isset($_COOKIE['postflood']) won't ever be true.

 

What method are you currently using to authenticate, identify, and determine if a visitor can post on your site?

Link to comment
Share on other sites

You could use two cookies, one would be set with a unique id value (and store the unique value in a database table so that you can check if the visitor didn't just put some random value into a cookie) and the second one would be set to determine when the last post was. You would test to make sure the unique value cookie was provided to make sure that cookies were being accepted and sent back to the server and that the unique value was one that you assigned and that the last post cookie was not set.

 

You should also regenerate and reset the unique id cookie upon each post so that they cannot get one valid unique id cookie and keep posting by deleting the 'postflood' cookie.

 

If they don't accept cookies, they delete both of them, or they did not get a unique id value from you, you won't allow them to post.

Link to comment
Share on other sites

Yes you could use sessions, but then all i have to do is clear my cache and post again 2 seconds later.

 

I would reccommend using a login system that put the timer into that users details table. That way the only way to bypass is to make a new account, with a new email - which most people really wont bother with).

 

-cb-

Link to comment
Share on other sites

Using just a session with the time of the last post stored in it can still be easily bypassed (see ChemicalBliss's post.)

 

You would need to persistently store (database table) the session id and the visitor's IP address so that you can make sure that they are keeping the same session that they started with and are not simply dropping the session id and getting a new session each time.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.