Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tbasoft@gmail.com's avatar

Laravel 5.3 Session Null After Set

I have a simple application written with Laravel This program works well on localhost But when I transfer it to a shared hosting Session are set and store in storage/freamwork/session but when get them on another route or class there are null! all folder has 775 previlage(test 777 for session but no solve my problem)

this is my code i get Redirecting to http://***.org/login after login becuse session value is null also csrf protection not working on sherd host i also put all route need to session on middleware web -->but not working also i use Session::save(); but not working

i add two route


Route::get('/session',function (){
    session(
        ['username'=>"hi",
            'Name'=>"myname",
            'Lname'=>"mylname"]);
    var_dump(session()->all());
    Session::put('key', 'value');
    var_dump(session()->all());
});


Route::get('/session2',function (){
    var_dump(Session::get('key'));

});

after /seesion return:


array(4) { ["_token"]=> string(40) "Nn0zaXUO43Npo0nCwWVCQ1vcKIMs2kNeWHSKxzhZ" ["username"]=> string(2) "hi" ["Name"]=> string(6) "myname" ["Lname"]=> string(7) "mylname" } array(5) { ["_token"]=> string(40) "Nn0zaXUO43Npo0nCwWVCQ1vcKIMs2kNeWHSKxzhZ" ["username"]=> string(2) "hi" ["Name"]=> string(6) "myname" ["Lname"]=> string(7) "mylname" ["key"]=> string(5) "value" } 

after /session2 return: NULL

  #drivers: array:1 [▼
    "file" => Store {#130 ▼
      #id: "v6EDxmv3K2eGu3T2W1K1V248j7dXCJ86nvIQ8quP"
      #name: "laravel_session"
      #attributes: array:1 [▶]
      #bags: []
      #metaBag: MetadataBag {#122 ▼
        -name: "__metadata"
        -storageKey: "_sf2_meta"
        #meta: &29 array:3 [▶]
        -lastUsed: 1482487477
        -updateThreshold: 0
      }
      #bagData: array:1 [▶]
      #handler: FileSessionHandler {#131 ▼
        #files: Filesystem {#91}
        #path: "/home/kavoshg7/newkernel/storage/framework/sessions"
        #minutes: 120
      }
      #started: true
0 likes
0 replies

Please or to participate in this conversation.