New to Laravel and having some problems with Sessions.
In my Linux server I have some PHP scripts stored on sub-domains, one of them is with Laravel.
I set all of them like so:
session_name("examplecom_session");
session_set_cookie_params(0, '/', '.example.com');
session_start();
I can retrieve all my $_SESSION
data array across all my sub-domains except in Laravel.
How can I solve this?
You can get your session variables with Laravel session() function. like
$a = session('VariableA')
it will return session $variableA or if you want to set $variableA as a session variable you just do: session('variableA', 'value')
Doing session('variableA, 'myvalue')
will actually set myvalue
as the default value, this is not the correct way to set the value of a session variable.
Instead you would do session(['variableA' => 'myvalue'])
to set the session using the global helper.
Most settings are done in the config files regarding your question about session_set_cookie_params
.
I would recommend you to read up on it at https://laravel.com/docs/5.5/session#storing-data