Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sunrise's avatar

How to validate session in Laravel 5.2?

I am using Laravel 5.2,
I added a verification code input in register form,
verification code was saved in session when making it,
the question is:
How to write the validation rule of verification code in function validator,

AuthController.php

    protected function validator(array $data)
    {
        $verification_code_session = $request->session()->get('verification_code', '');
        return Validator::make($data, [
            'name' => 'required|max:255',
            'email' => 'required|email|max:255|unique:users',
            'password' => 'required|confirmed|min:6',
            'verification_code' => '',// How to write the validation rule? 
        ]);
    }
0 likes
1 reply

Please or to participate in this conversation.