当前位置:网站首页>Tp5 in cache cache, storage cell phone text message authentication code
Tp5 in cache cache, storage cell phone text message authentication code
2022-08-08 23:06:00 【Also believe that light?】
Set the mobile phone SMS verification code cache method:
/*** Set up mobile phone SMS verification code cache* #User: JW* #Email:[email protected]* #Date:* @param $data_cache*/public function setRegSmsCache($data_cache){Cache::set('sms_' . $data_cache['mobile'], $data_cache, 300);}
Move the mobile phone SMS verification code cache method
public function send_text_message()$data['time']=time()+60;//When the verification code expires, the setting here is to expire after one minute$data['mobile']='18888888888';//The mobile phone number that accepts SMS$data['code']= rand(100000,999999);//Get 6-digit SMS verification code randomly$this->setRegSmsCache($data);}
Verify the mobile phone SMS verification code cache method:
/*** Verify that the verification code is correct* @param $mobile recipient* @param $code SMS verification code* @return json*/public function checkRegSms($mobile, $code = false){if (!$mobile) return false;if ($code === false) {if (!Cache::has('sms_' . $mobile)) return true;if (Cache::get('sms_' . $mobile)['times'] > time()) {return false;} else {return true;}} else {if (!Cache::has('sms_' . $mobile)) return false;if (Cache::get('sms_' . $mobile)['code'] == $code) {return true;} else {return false;}}}
Movement verification mobile phone SMS verification code cache method
public function verification_code()$mobile='18888888888';//Mobile phone number that needs to be verified$code='100000';//Received verification code$this->checkRegSms($mobile,$code);}
边栏推荐
猜你喜欢
随机推荐
wsgw login packet capture record
The second side of Tencent technical support internship - Tencent's father's luck is so sudden (offer received)
想要精准营销,从学习搭建一套对的标签体系开始丨DTVision分析洞察篇
Button Wizard Delete File Command
ALIPAY WEB 登陆rsa加密 分析记录
免费ARP
MySQL给表里的某个字段建立索引
让IPv6强大的关键——NDP邻居发现协议
ABP中的数据过滤器
如何实现call、apply、bind
C语言 库函数汇总2019.10.31
JSDay2- 长度最小的子数组
如何使用 Eolink 实现 API 文档自动生成
【Verilog基础】关于芯片中信号串扰的理解
sess.restore() 和 tf.import_meta_graph() 在使用时的一些关联
最详树莓派4B装机流程及ifconfig不到wlan0的解决办法
ArcPy设置全库唯一标识码
深拷贝与浅拷贝
Kubernetes与OpenStack
2021 RoboCom 世界机器人开发者大赛-本科组(决赛)7-4猛犸不上 Ban(最短路)