title: session not working properly in php Laravel
body: <p>I have a session problem in my Laravel project when uploaded on hostgator server. The session driver is a file type issue. When I try to login I set global session like <code>session(['user'=&gt;1,'username'=&gt;'zee']</code>)  </p>
  
  <p>When I am redirected to another route and try to access session values  the session is empty. Before redirecting if I <code>print_r(session('user'));</code> the value printed means working fine on the same controller.</p>
  
  <p>Can anyone suggest a solution?</p>
  
  <pre><code>use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Auth; 
  use App\User;
  use Validator;
  use Session;
  
  class userLoginController extends Controller
  {
      //
      public function user_login(Request $request)
      {
         if(Auth::attempt(['email' =&gt; request('email'), 'password' =&gt; request('password')]))
             {
                     $user = Auth::user(); 
                     $request-&gt;session()-&gt;put('aa_key', 'value');
                       session(['user' =&gt; $user-&gt;name,'user_data'=&gt;$user-&gt;id]);
  
                     return redirect()-&gt;route('user_dashboard')-&gt;with(['user_data'=&gt;1]);
            }
            return redirect()-&gt;route('all');
      }
  
  
  
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Auth; 
  use App\User;
  use Validator;
  use Session;
  
  class userLoginController extends Controller
  {
      //
      public function user_login(Request $request)
      {
         if(Auth::attempt(['email' =&gt; request('email'), 'password' =&gt; request('password')]))
             {
                     $user = Auth::user(); 
                     $request-&gt;session()-&gt;put('aa_key', 'value');
                       session(['user' =&gt; $user-&gt;name,'user_data'=&gt;$user-&gt;id]);
  
                     return redirect()-&gt;route('user_dashboard')-&gt;with(['user_data'=&gt;1]);
            }
            return redirect()-&gt;route('all');
      }
  }
  </code></pre>
  
  <p><strong>another controller</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers;
  use Illuminate\Support\Facades\Auth; 
  use App\post;
  use App\category;
  use App\subcategory;
  use App\attribute;
  use App\attribute_value;
  use App\post_attribute;
  use App\midea;
  use App\User;
  use App\like; 
  use App\rating; 
  use Illuminate\Http\Request;
  use Redirect;
  use Session;
  use Carbon\Carbon;
  
  class FrontController extends Controller   public function userdashboard(Request $request)
      {
            $flg = session('user_data');
            $ad =Session::get('aa_user');
            //dd($flg);
            print_r($ad);
            exit;
      }
  </code></pre>
  
  <p><strong>web.php</strong></p>
  
  <pre><code>Route::post('/userlogin', 'userLoginController@user_login'); 
  
  Route::get('/user_dashboard', 'FrontController@userdashboard')-&gt;name('user_dashboard');
  </code></pre>