Support the ongoing development of Laravel.io →
Session Validation

Hi

I am using Laracasts Form Validation Simplied (https://github.com/laracasts/Form-Validation-Simplified) approach in my project. I've an event listener set up to catch any form validation failure:

// Catch validation error
$app->error(function(\Extensions\Tpp\Forms\FormValidationException $e)
{
	return \Redirect::back()->withInput()->withErrors($e->getErrors());
});

Then redirects back to previous page with Session Flash message

However the problem I've got is the session data stores twice. When it redirects back to the previous page, it shows the validation error, which is good, however if I refresh the page, I can still see the validation(Odd!), and I refresh the page again, the validation error disappears.

Thank you for your advice!

Last updated 3 years ago.
0

This may help.! After displaying the error, Remove the item from the session

Session::forget('key');

Add this after displaying error where 'key' is the item.

Last updated 3 years ago.
0

Hi Sikandhar,

Thank you very much for your reply. I believe Session::forget('key'); will work as well, but I am inclined to figure out why Session::flash('key') doesn't get flushed after the following request.

Last updated 3 years ago.
0

By the way, I am using Laravel 4.0.9, the session drive is native.

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

liamqma liamqma Joined 9 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.