Port 8080
Port 8080

Reputation: 888

Restricting page access before submitting other page in laravel

I have an application that requires 3 step to register. Those steps where separated as pages.

Now my question is, how can I prevent access to /step/2 if the user doesn't submit the form from /step/1 properly and same with /step/3 if the user doesn't submit /step/2 properly?

I'm still new to laravel.

Upvotes: 0

Views: 657

Answers (1)

ollieread
ollieread

Reputation: 6301

Use sessions. Upon successful submission of each step, do something like:

Session::put('registration_step', 1);

Then at the start of the next step, do something like:

if(!Session::has('registration_step') || Session::get('registration_step') != 1) {
    return Redirect::to('/step/1');
}

You could even flash it using Session::flash() and then reflash when necessary.

Upvotes: 1

Related Questions