Don't mind the EpochTime and Comments - they all working properly.
Code: Select all
:foreach i in=[ip hotspot user find where name!=admin and name!=default-trial and ! disabled ] do={
:global EpochTime;
:local epoch [$EpochTime];
:local ts [ip hotspot user get $i comment];
:local user [ip hotspot user get $i name];
#:log info message=("DEBUG User: ".$user.", Expires: ".$ts.", Epoch: ".$epoch);
:if ($ts!="") do={
:local ts1 [:tonum [ip hotspot user get $i comment]];
:if ($epoch >= $ts1) do={
:log info message=("EXPIRED user: ".$user.", Expires: ".$ts1.", Epoch: ".$epoch);
# Works OK:
/ip hotspot user set disabled=yes $i;
# PROBLEM - Instead of removing only that user's cookies (if any) - removes all cookies:
/ip hotspot cookie remove [/ip hotspot cookie find user=$user];
# PROBLEM - Instead of removing only that user's active sessions (if any) - removes all sessions:
/ip hotspot active remove [/ip hotspot active find user=$user];
}
}
}