Trying to set and get session in laravel. In my controller I'm converting an array to string which doesn't throw an error if printed, however froim the error looks like session is getting an array instead of a string. Controller:
public function getQuestions(){
$questions = DB::table('questions')->orderBy(DB::raw('RAND()'))->get();
$questions= json_decode(json_encode($questions), true);
Session::put('questions', $questions);
return view('test', array('questions' => $questions));
}
Blade:
{{ Session::get('questions') }}
An error:
htmlentities() expects parameter 1 to be string, array given