Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using $_SESSION in Laravel From non-laravel project

In my company, we make login in one application (non-laravel). When the login is made, we store the session info in the $_SESSION variables, like $_SESSION['XPTO'].

The user has access to a lot of tools (all non-laravel) and we use everywhere the $_SESSION['XPTO'] to get the data that we need about the authenticated user.

The problem is that I developed a new tool with Laravel 5.3 and I need to get the data that is inside the $_SESSION variables. I think laravel do not use the native php sessions!

So, how can I get that information?

Thanks in advance

like image 580
Erbi Silva Avatar asked Oct 11 '16 12:10

Erbi Silva


2 Answers

to access $_SESSION, simply place session_start() at the beginning of the index.php file of your laravel-project

like image 199
FabriceJ Avatar answered Oct 14 '22 12:10

FabriceJ


Laravel doesn't use native PHP sessions since Laravel 5.

We are no longer using Symfony's (and therefore PHP's) session handling facilities, and are using a custom solution that is simpler and easier to maintain

In Laravel you want to use Session:: facade or session() global helper to work with sessions:

// Saving value.
session()->put('key', 'value');

// Gettinng value.
session('key');
like image 22
Alexey Mezenin Avatar answered Oct 14 '22 12:10

Alexey Mezenin