0

I am working on OTP based authentication system. I want to keep the OTP code in a session variable. and it must forget in 5 min in generating time. is it possible to use session or do need to use cookies?

 $otp_code = random_int(10000, 99999);

        session()->get('otp_code');
        session()->forget('otp_code');
        $session = Session::put('otp_code', $otp_code);
Code Kris
  • 447
  • 3
  • 19
  • 2
    You could add another session variablelike Session::put('otp_code_initial_time', time());.. and then validate time when needed – fluid undefined Sep 21 '22 at 04:46
  • 1
    Please check this link for your reference https://stackoverflow.com/questions/17179249/session-destroy-after-certain-amount-of-time-in-php – Siva Sep 21 '22 at 04:56

0 Answers0