php使用session限制访问频率、接口请求频率
$seconds = '10'; //时间段[秒]
$refresh = '8';//最大次数
$cur_time = time();
if(Session::get('last_time') && $cur_time - Session::get('last_time') < $seconds){
if(Session::get('refresh_times')){
if(Session::get('refresh_times') >= $refresh){
$this->error('system error'); //返回提示
}else{
Session::set('refresh_times',Session::get('refresh_times')+1);
}
}else{
Session::set('refresh_times',1);
}
}else{
Session::set('refresh_times',1);
Session::set('last_time',$cur_time);
}