我想把钥匙藏起来
$code = mt_rand(111111, 999999);
Cache::put('notification', $code, 600);
在另一个函数中,我试着用这种方法得到那个键
if(Cache::has('notification') and Cache::get('notification') == $request->code)
return response()->json(['status' => true, 'group' => $request->res['group']]);
else
return response()->json(['status' => false, 'message' => 'کد اشتباه است']);
但它总是返回false
1条答案
按热度按时间332nm8kg1#
问题可能是当您使用
Cache::get()
您没有将值存储在任何位置。请尝试将其存储在变量中,并将变量与$request->code
.