this is my very first question here and may not meet some standards, for that i apologize in advance. I have a site developed in laravel 5 where the users register and are expected to make take an action within a specific period after registration. I have included a countdown timer for that purpose (the time code is shown below). Now I need to automatically remove a user record from the database when the time runs out. Please how can I do that? the timer code is:
<div class="getting-started"></div>
<?php
$time = strtotime($user['updated_at'].'+24 hours');
$countdown = strftime('%Y/%m/%d %H:%M:%S',$time);
?>
<script type="text/javascript">
$(".getting-started")
.countdown("{{$countdown}}", function(event) {
$(this).text(
event.strftime('%H:%M:%S')
);
});
</script>
If you want something to happen on the server, then you should maintain the timer on the server side, not the client side. Otherwise, the user can simply change the timer or otherwise block the action that the expiration is meant to trigger. I would store a timestamp with the user record, noting when it was created. Then write a script to loop over all records that are older than your threshold and perform the desired action on them. Then run this script via a cron that fires at a regular interval.