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

saadaan's avatar

Getting SESSION variable value in FORM

Hi

I am trying to pull a variable value in the form. In simple blade, I know that I can do {{Session::get('message')}} to get the value. But I am building a form, and cannot use {{ }} because it makes the form go whack:

{{ Form::text('dt1_id', {{Session::get('dt1_id')}}) }}

Is there a way to get the value there? I tried to use @php @endphp, but can't seem to figure out how to call the session variable in it. The standard $_SESSION['dt1_id'] does not work.

Regards Saad

0 likes
1 reply
rin4ik's avatar
rin4ik
Best Answer
Level 50

with this?

{{ Form::text('dt1_id', session()->get('dt1_id')) }}

or

{{ Form::text('dt1_id', Session::get('dt1_id')) }}

Please or to participate in this conversation.