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

ethar's avatar
Level 5

send session to view not working

i return this session fro controller

 return view('front.userlogin')->with('message', 'IT WORKS!');

in blade i check if session exist, and if exist print data

@if(session()->has('message'))
      <div class="alert alert-success">
              {{ session()->get('message') }}
       </div>
 @endif

but not working

0 likes
3 replies
marouanaf's avatar

Hi @ethar, @silencebringer pointed you correctly, to retrieve the data that you send you can use the following code, otherwise you can check the link that @silencebringer mentioned to learn how to pass it via the session

@if(!empty($message))
  <div class="alert alert-success"> {{ $message }}</div>
@endif
Snapey's avatar

use the session to pass a message on the next request not the current one

When returning a view just pass the data directly

Please or to participate in this conversation.