Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

frankhosaka's avatar

Undefined type 'Session' Intelephense (1009)

This is a piece of code where VS Code show error:

<?php $data = Session::get('success'); ?>

It is in messages.blade.php (https://codeanddeploy.com/blog/laravel/laravel-8-authentication-login-and-registration-with-username-or-email).

I installed https://github.com/barryvdh/laravel-ide-helper#installation but the error remains.

0 likes
8 replies
Sinnbeck's avatar

Why not do that in the controller and pass it down as data if it needs to be bound to a variable? Or just use this wherever you need it

{{session('success')}} 
2 likes
frankhosaka's avatar

@Sinnbeck thanks a lot. I change code

<?php $data = session('success'); ?>

I'am new in Laravel, i just copied the tutorial, i don't know how work with controller yet. But now VS Code doesn't point no error. Thanks a lot.

Sinnbeck's avatar

@frankhosaka I would recommend setting variables like that in views. Can you show what you need it for?

1 like
frankhosaka's avatar

@Sinnbeck i just copied from tutorial, i want to study the login logic. I use classical method try and error. Right now, i don't have any idea how use login neither how use Laravel arquitecture. I am a simple curious, not a professional developer.

Today, I learned that Intelephense is a important VS Code component, it alerts when i use local variable instead global variable. There are many tutorials to deactive Intelephense, but I understand that is not good choice.

frankhosaka's avatar

Thanks again. My first trouble is that my English is very very very limited. I am from Brazil.

Sinnbeck's avatar

@frankhosaka I'm understanding you quite well. From Denmark myself. So keep it up. I know it's a leaning curve, but practicing English is a useful thing when learning programming

1 like
saharshanah's avatar

in controller define path of session (use Illuminate\Support\Facades\Session;)

Please or to participate in this conversation.