Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Time Range

Status
Not open for further replies.

EastIndian

Technical User
Mar 21, 2002
18
0
0
US
(Forgive, I am still a beginner..)
I am wanting to determine if a user's IP has accessed my site in any random time between now and the past 5 minutes. (I know cookies are the way to go for tracking, but please bear with me). I am currenly collecting the IP along with time that site was accessed in a database. (I know this can get really big, it's just a temp tracking process for study). Can anyone give me a hint how to write a statement that that will generate a random time in the past 5 minutes and function to say "if the current IP has accessed this site between now and some random time within the last 5 minutes, then abort." Any suggestions would be welcome. Thanks in advance.
 
You don't need to generate a random time; all you need to do is check to see if the date in the database that corresponds to the ip address you want to check is 5 minutes less than the current time #Now()#:

<cfif DateDiff(&quot;n&quot;,DateInDB,Now()) LT 5>
...Deny Access
<cfelse>
...Allow Access
</cfif>

You could also do this in a database query and just check the field result, depending on what RDBMS you are using.


-Tek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top