mercredi 28 juillet 2021

cookie::make does not save the cookie in Laravel 8

Am I missing something? I am pulling my hair to solve this simple use of cookie. My intention is simply to save a variable for each user (I tried session and there were side effect issues). The below code should theorically save the cookie which should be there at the next call of the page, correct? It does not work. What am I missing?

class TestController extends Controller
  {
  public function show($page) {
    echo @Cookie::get('testcookie');
    if (Cookie::get('testcookie')) { echo 'cookie exists<br>'; } 
    else { echo 'cookie does not exist<br>'; }
    $cookie = Cookie::make('testcookie','5', 120);
    echo $cookie;
    return view('tests.'.$page,['page' => $page]);
  } 
}

I have also modified config/session.php as recommended for use on http://localhost. Should I clean/cache... or similar after that. I am using laravel 8 & FF on OSX.

'secure' => env('SESSION_SECURE_COOKIE', false)

Can someone please tell me what I am doing wrong?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire