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

professor08's avatar

Laravel 5.6, validation errors in session

Hello everyone,

I am new to Laravel and I am using the older version in an application. How can we set the validation errors from $this->validate() in the session ?

I have tried the Validate::make() but still getting "Session is missing expected key [errors]".

Please help!

Thanks

0 likes
5 replies
professor08's avatar

@Nakov Yes I tried Validator::make(), but still getting the same "Session is missing expected key [errors]".

Nakov's avatar

@professor08 This is the most important part:

if ($validator->fails()) {
		return redirect('post/create')
        		->withErrors($validator)
                ->withInput();
}

notice the withErrors($validator) which puts the 'errors' into session.

Please or to participate in this conversation.