Mahsa
Mahsa

Reputation: 373

count time of button click in 1 minute

i use asp.net and ajax

I have a button and I want to count that, how many times was the button clicked in 1 minute. if the user clicked the button more than 5 times in 1 minute it will be deny for 5 minute. what is the best solution.?

Upvotes: 2

Views: 1109

Answers (2)

Espo
Espo

Reputation: 41939

One way of doing this is to store the datetimes that the user has clicked the button in a session-object. That way, the user can not change the value unless he restarts the browser.

Upvotes: 0

Arve Systad
Arve Systad

Reputation: 5479

Store the times for each button-click (DateTime.Now) in a hidden value or somewhere you prefer (be it a database, an XML-file or whatever else). Then, every time the button is clicked, get the 1-5 latest click-times and see if they are within the last minute. From there on, you can deny access, set database-flags or do whatever you like.

Here is some reading about DateTime.

Upvotes: 1

Related Questions