0

At first.

I saw this questions: Laravel 5 - session put not working Laravel session key is null after put in session laravel session returning null inspite of setting it Laravel 5 - session doesn't work

Trying to modify my code but nothing changed.

Problem:

On http://localhost:8000/session/set - trying to save the session (var_dump returning NULL) On http://localhost:8000/session/get - trying to get this session which i saved but it doesn't.

My code in SessionController.php:

    class SessionController extends Controller{
        public function accessSessionData(Request $request){
            if($request->session()->has('name')){
                    var_dump($request->session()->get('name'));
            }
            else{
                    echo 'No data in the session.';
            }
            }

            public function storeSessionData(Request $request){
                    var_dump($Crequest->session()->put('name','Filip'));
                    echo "Data has been set.";
            }
}

My code in route.php:

Route::get('session/get', 'SessionController@accessSessionData');

Route::get('session/set', 'SessionController@storeSessionData');

Route::get('session/delete', 'SessionController@deleteSessionData');

In session.php driver set to file with standard storage_path.

Folder which storage sessions - chmod 755

Any ideas ?

Community
  • 1
  • 1
kjugi
  • 3
  • 1
  • 8
  • ok, nevermind. I just follow this way: 1. In terminal: `composer require illuminate/html` 2. add in config/app.php in providers `Illuminate\Html\HtmlServiceProvider::class,` 3. in the same file: `'Form' => Illuminate\Html\FormFacade::class, 'Html' => Illuminate\Html\HtmlFacade::class,` 4. save file 5. restart serv and everything (restarted computer too) And pull() returning null in var_dump() even if it works – kjugi Sep 04 '16 at 17:47

1 Answers1

0

You can to use another approach to store/get data from session with using function session();

Get the session object: $session = session();

Put a new value to session: $session = session(['key' => 'value']);

Get a value from session: $value = session('key');

Andrej
  • 7,474
  • 1
  • 19
  • 21