#Laravel 11X Session var not working

1 messages · Page 1 of 1 (latest)

hot wing
#

My first question would be; why are you doing all this? You're basically fighting the framework in so many ways. Laravel would manage the session for you, that's why you'd use a framework. You're starting the session extremely late in the request lifecycle, which would likely interfere with Laravel, as you are using Laravel to pull data from the session.
My recommendation, if you're learning PHP, don't start with a framework, learn PHP. Then using a framework would make a lot more sense, as the framework would do a lot of things for you already.
Like, all of what you're doing is already built-in to Laravel, it's all documented in the authentication docs; https://laravel.com/docs/11.x/authentication

hallow merlin
hallow merlin
hot wing
#

But the docs already explain how to do it? That's what I just linked, it tells you all about authentication and how to do that.

hallow merlin
hot wing
#

Guess I don't understand the issue then. Because you're calling session_start() in a controller, which is really late in the lifecycle of a request, and this would already be taken care off by Laravel in the web.php routes through the default web middleware group

hallow merlin
hallow merlin
# hot wing But the docs already explain how to do it? That's what I just linked, it tells y...

Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.

#

Plus it wont help me "make it by myself instead of using Laravel Libs and built in login components". I simply don't understand why the *** session var won't stay