0

I written a registration system in Classic ASP. user signup and will receive an activation email. I want to delete records ( users ), if user did not active their account by clicking on activation link was sent to after 24Hrs.

how can do it?

my users table have these rows ( I'm using Access):

UserID     text
Username   text
Password   text
Email      text
Hash       text
join_date  date/time
active     Yes/No

P.s: I've no access to IIS configuration beacause my website is stored on a public server and not on a dedicated one

MAY3AM
  • 1,182
  • 3
  • 17
  • 42
  • Why not run a script every night that queries the database and deletes any records that were created more than 24 hours ago and are not yet active? Do you really need to delete the account exactly 24 hours after it was created? – Liron Jul 26 '12 at 13:05
  • I want to delete the accounts that were not activated after 24 hrs! – MAY3AM Jul 26 '12 at 13:10
  • I don't understand your question then. You know when they joined, and you know the time now. You also know whether or not they activated their account. So all you have to check is whether it has been 24 hours since they joined. If Now - joined_date > 24 hours && active = false, delete the whole user row. – Liron Jul 26 '12 at 13:14
  • Yeah I know how must do it! ( I'm using DateDiff() )but problem is how can do it automatically!! by schedule :) – MAY3AM Jul 26 '12 at 13:19
  • Not with classic ASP. Have standalone VBScript (most simple way) file and schedule it to run every 24 hours. – Shadow The GPT Wizard Jul 26 '12 at 13:49
  • Can you explain it for me pls? – MAY3AM Jul 26 '12 at 14:03
  • Have a look at that suggestion, may be helpful http://stackoverflow.com/questions/11561965/asp-classic-how-to-schedule-a-function-server-side/11567959#11567959 – Kul-Tigin Jul 28 '12 at 00:42
  • Thanks Man, was useful for me ;) – MAY3AM Jul 29 '12 at 18:47

1 Answers1

0

If you can't create a scheduled task to run an ASP script, then the next best thing might be to do this in global.asa in the Session_OnStart event. This runs every time a new session is started (a new user visits). If you set the last run time in an "Application" variable you can then choose to only run the routine to delete these users once a set time has elapsed. However, if you don't have frequent visitors to your site then it won't run often.

Sub Session_OnStart
   'Runs on application start or after 15 minutes
   If Application("LastRun") = "" Or DateDiff(n, Application("LastRun"), Now()) > 15 Then
       'Your code to delete users here, a query like this...
       'DELETE FROM [tableName] WHERE [active] = 0 AND DATEDIFF(hh, [join_date], GETDATE()) >= 24
       Application("LastRun") = Now()
   End If
End Sub
johna
  • 10,540
  • 14
  • 47
  • 72
  • Thanks John, but as you said it run when users visit the site, and the problem still remain, anyway thank you :) – MAY3AM Jul 27 '12 at 11:15