i want to pass langguageid
session from laravel to my vue component.
how i can do it?
i try like this, but not working.
my laravel session function
public function getLanguageSession($langid)
{
if (Session::has('LangSession')) {
Session::forget('LangSession');
$LangSession = Session::put('LangSession', $langid);
$getLangSession = Session::get('LangSession');
} else {
$LangSession = Session::put('LangSession', $langid);
$getLangSession = Session::get('LangSession');
}
return redirect('/');
}
and then i call it to vue function
public function getLanguageStringArray(Request $request, $langid)
{
$getLangSession = Session::get('LangSession');
dd($getLangSession);
}
this code return me null value.
You should not return json data from a controller using dd($getLangSession);
, this will give you a totally different output that cannot be parsed by Vue. You have to return the data as a json result to make sure Vue can read this:
public function getLanguageStringArray(Request $request, $langid)
{
$getLangSession = Session::get('LangSession');
return repsonse()->json($getLangSession);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.