0

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?

Simon Orro
  • 184
  • 7
  • 20

2 Answers2

1

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

coleander
  • 551
  • 6
  • 10
  • but I don't set the main session in a Laravel environment. Basically in Laravel I need to retrieve my session name (created on a different not Laravel main domain) – Simon Orro Nov 09 '17 at 19:25
0

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')

Radu
  • 995
  • 12
  • 23