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

priti's avatar

How to populate session data in form elements

In controller, if I have model populated following

{{Former::open->method('get')}}
{{Former::text('email')}}
{{former::close}}

text box is populated with email, but for now I want to populate with session data instead of model . Any idea who to bind form element with session data. I am using Former form library and laravel4. Any help is appreciated.

tried creating a variable and assign it to blade but not working

$email = $sessinfo['email'];
return View::make('test',compact('email'))
0 likes
4 replies
jlrdw's avatar

Shouldn't that be:

$email = Session::get['email'];
priti's avatar

No it's not working , I am trying to populate the form field while click Back button which is redirecting me using {{URL::previous()}}

jlrdw's avatar

Don't totally understand what uou are after, but are you sure you are storing correctly in session?
Comment out you return view line and try

$email = Session::get['email'];
echo $email;

Make sure you actually have value stored in the session.

priti's avatar

Yes, session values are correctly added and removed. I can use the session variables in my program further. I guess this issue is more with Former form library for laravel which is used for displaying form and it's element.

Please or to participate in this conversation.