Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to store an array as flash data in Laravel?

I have been looking around for a way of doing this. I know it is possible to store an array in the session with the following: Session::push('user.teams', 'developers');

Is it possible to do the same but with flash data? Something like Session::flashpush('user.teams', array('developers', 'designers')); would be great.

The usecase for me at this moment is primarily the following:

Session::flash('flash_message', $validator->messages());

like image 652
AntonNiklasson Avatar asked Nov 04 '13 21:11

AntonNiklasson


People also ask

What is flash data in laravel?

Summary. Flashing data to the session stores short-lived data and can display it in the application. It is usually used to display status after an action. RELATED TAGS. laravel.

What is session in laravel?

Sessions are used to store information about the user across the requests. Laravel provides various drivers like file, cookie, apc, array, Memcached, Redis, and database to handle session data. By default, file driver is used because it is lightweight. Session can be configured in the file stored at config/session.

How can I change session in laravel?

Laravel session configuration is stored in config/session. php file. By default, Laravel store session data in files. If you want to store session in database table, then change session driver to database and run bellow command to generate sessions table.


1 Answers

I use this:

Session::flash($key, array_merge((array)Session::get($key), array($value)));
like image 75
conradkleinespel Avatar answered Oct 20 '22 01:10

conradkleinespel