brobrobrobrobro
brobrobrobrobro

Reputation: 314

Cannot call variables $_SESSION inside controller Laravel 5

I need to call $_SESSION in laravel controller, because I placed laravel in a subfolder of another website so I need to get the session from another website. But because of I call $_SESSION inside controller, the redirect thing is not working and shown like this when I run php artisan route:list:

enter image description here

Anyone can help me to call $_SESSION from laravel controller? Thank you.

Upvotes: 0

Views: 304

Answers (2)

Manjeet Vishwakarma
Manjeet Vishwakarma

Reputation: 101

For Session's in Laravel you can refer https://laravel.com/docs/5.4/session

Upvotes: 1

Gowthaman D
Gowthaman D

Reputation: 578

That's Wrong

Please Do like this

Controller or model or route

Anywhere

 use Session;

$request->session()->put('`key`', 'value');

use Illuminate\Support\Facades\Session;

if (session('id') != null){
   echo 'Success'
 }

Or use the session() helper:

For Your Reference https://laravel.com/docs/5.1/session

Upvotes: 1

Related Questions