Support the ongoing development of Laravel.io →
Requests Session Views
Last updated 2 years ago.
0

In your controller:

        $value = $request->cookie('test-cookie');

        if ($value == 'test') {
            return view('view-with-no-form');
        }

        $view = view('view-with-form');

        $response = new Response($view);

        $response->withCookie('test-cookie', 'test', 60);

        return $response;
0

Hi @ssomenzi.

I'm not quite sure how this will work according to what I say above.

  1. Submitting a form via AJAX
  2. In the method that handles the AJAX request, I set a cookie valid for an hour.
  3. On a complete different method/route I need to retrieve the value of the previous cookie

Hope this make sense

0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.

© 2024 Laravel.io - All rights reserved.