Laravel 5.2.11, sessions do not work, session cookie is not set

I'm new to Laravel, I learned about models, views, blade, controllers and routes and how they work together. So far, everything is working smoothly.

I have problems with sessions.

When I use the AuthController that comes with Laravel and removes auth / register using a POST request, the data for the user I register is inserted into the users table (using mysql) and I return the response using the "Location" header redirected to / as it does out of the box. It is redirected as it should. But in the same answer there is no Set / Set header of the Set-Cookie header. The serial part of Laravel is not working properly for me. This is the same for POST for authorization / login, it is authenticated correctly and redirected to the profile page, but the session cookie is not sent in response.

I use:

  • Laravel 5.2.11
  • PHP 5.5.9
  • xubuntu 14.04 (Ubuntu)
  • Linux kernel 3.19.0-42-generic
  • Composer 1.0

php, Laravel, . php, -. sudo. , , :

sudo php -S localhost:8888 -t public/

.

Laravel, , laravel -. , cookie . laravel mod 777. .env, .

config/session.php . storage/framework/sessions .

, :

session(['sesskey' => 'somevalue']);

"Set-Cookie" , . , .

, , :

echo session('sesskey');

, , , , , php.

cookie withCookie, Set-Cookie:

return response()->view('welcome')->withCookie(cookie("test", "val" , 3600));

, , , .

, !

+3
2

laravel 5.2 "" ,

Route::group(['middleware' => ['web']], function () {
//
});
+9

\Illuminate\Session\Middleware\StartSession:: class

Route::group(['middleware' => [\Illuminate\Session\Middleware\StartSession::class]], function () {

});
0

Source: https://habr.com/ru/post/1686771/


All Articles