Im newbie to laravel, So i got this problem with the session. Im actually fetching a xml response and converting it to an array and storing it to session:
Here is my controller that is accepting the request, convert the response to array and storing it on session.
public function HotelSearch(Request $request){
$rezlive = new RezLiveSearch();
$rezliveSearch = $rezlive->hotelSearchByCountry($request);
$request->session()->put('hotelSearchResult', $rezliveSearch);
$theResult = $request->session()->get('hotelSearchResult');
return view('search-result',compact('theResult'));
}
So it was storing and i can view the search result on my view page. But when i navigate to other pages that session which i just stored is not carried over. I tried to store a normal string and its working fine i can access it all over the application. Any one can help me with this please ?
BTW i'm using laravel 5.4
$rezlive = new RezLiveSearch(); $rezliveSearch = $rezlive->hotelSearchByCountry($request); $request->session()->put('hotelSearchResult', $rezliveSearch);
An resource can't be stored in session.
from php manual
http://php.net/manual/en/language.types.resource.php
A resource is a special variable, holding a reference to an external resource.
You need to fetch the XML data from the resource and store it to session, alternatively you can store into cache the XML , associate it with an random generated ID and avoid placing too much information in session.
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.