When I receive the session variable I always receive [object Object],[object Object] I have filled the session variable from the controller, but I can not extract the values, I do not know why it always shows me the object. My code is the following public function getrooms() { $Hab = \Session::get('bookcart'); return response()->json(['Hab'=>$Hab]); }
in javascript is so
var roomadd1 = function()
{
var route = "getrooms";
$.get(route, function(data){
var selec = eval(data);
console.log("Este es el valor"+selec['Hab']);
});
}
You can try this code:
public function set($key, $value) { if (is_array($value) && isset($_SESSION[$key]) && is_array($_SESSION[$key])) { $_SESSION[$key] = ArrayHelper::merge($_SESSION[$key], $value); } else { $_SESSION[$key] = $value; } } ... \Yii::$app->session->set('myvar',['subKey' => 'value']);
By:Xtreem Solution
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community