code-8
code-8

Reputation: 58652

How can I print out session message in Laravel?

I'm trying to print out my session/flash message to my user(s) as feedback.

I couldn't get it to display, worse than that, it give me the error.

enter image description here


view

{{-- Flash Message --}}
@if($success_register)
@if ($message = Session::get('success_register'))
<div class="alert alert-block alert-success">
  <i class=" fa fa-check cool-green "></i>
  {{ nl2br($message) }}
</div>
@endif
@endif

controller

return Redirect::to('/')
    ->with('success_register',' Your Account has been created ! <small> Email has been sent to set-password, and activation.</small>');

Upvotes: 0

Views: 2567

Answers (1)

Mathieu Dumoulin
Mathieu Dumoulin

Reputation: 12244

You should use Session::get('success_register') on both occassions simply said!

@if(Session::has('success_register'))
    <div class="alert alert-block alert-success">
        <i class=" fa fa-check cool-green "></i>
        {{ nl2br(Session::get('success_register')) }}
    </div>
@endif

Upvotes: 3

Related Questions