RPeraltaJr
8/21/2019 - 9:21 PM

Setting or Getting a Session

<?php 

Route::get('/', function() {
  // set session
  session(['name' => 'John Doe']); 
  
  // use/call a session
  session('name');
  
  // return session variable (also has a default value just in case)
  return session('name', 'A Default Value');
  
  // delete a session
  session()->forget('name');
  
  return view('welcome');
});