[英]Laravel 5.4 Session is not retaining
Im newbie to laravel, So i got this problem with the session. 我是laravel的新手,所以我在会话中遇到了这个问题。 Im actually fetching a xml response and converting it to an array and storing it to session:
我实际上是获取xml响应并将其转换为数组并将其存储到会话中:
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 顺便说一句,我正在使用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 来自php手册
http://php.net/manual/en/language.types.resource.php 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. 您需要从资源中获取XML数据并将其存储到会话中,或者您可以将XML存储到缓存中,将其与随机生成的ID相关联,并避免在会话中放置太多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.