你好,我有一个重定向到其他路由的路由,会话参数data=true,uid=$id
另一条路由获取它并显示一个Response::make/Response::view。视图显示,但若我用F5重新加载页面,会话数据就会丢失(路由并没有得到它)。
Route::get('/something', array('as'=>'activation',function()
{
return Redirect::route('firstpass')
->with(array('data'=>true,'uid'=>100));
})
);
Route::get('/something2',array('as'=>'firstpass',function()
{
if(Session::get("data")==true)
{
$uid=Session::get('uid');
return App::make('HomeController')->somePage($uid);
}
else return Redirect::to('/');
}
));
控制器:
public function somePage()
{
$params=array(
'title'=>trans('welcome.welcome'),
'lang'=>$lang=Config::get('app.locale')
);
$view = View::make('firstpass',$params)->with(array('data'=>true,'uid'=>10));
return $view;//
Response::view('firstpass',$params);//->with(array('data'=>true,'uid'=>10));
}
我不知道为什么在简单的重新加载后,路由无法获取:会话::get('data')==true并将我重定向到/。
但如果在控制器中我写die(print_r(会话:all()));我总是(即使刷新后得到):
Array
(
[_token] => 6n6qb2vTxuunraTKVXvfrBsJ1mCddOZkgwb
[flash] => Array
(
[old] => Array
(
[0] => data
[1] => uid
)
[new] => Array
(
)
)
[data] => 1
[uid] => 100
)
我认为原因是内部返回值,我尝试了响应::make,响应::view,返回view::,但这项工作都没有,我做错了什么?
也许该会话中的问题通过/app/storage/session 中的本地驱动程序存储数据
它创建文件,但每个请求中的数据都为空_sf2_attributes|a:2:{s:6:"_token";s:40:"XCJlvuFO2RCpKZYiW0Amm23DP5jwsmcC1Uq9vIS7B";s:5:"flash";a:2:{s:3:"new";a:0:{}s:3:"old";a: 0:{}}_sf2_frass|a:0:{}_sf2_meta|a:3:{s:1:"u";i:138724689;s:1:"c";i:1387123303;s:1:"l";s:4:"7200";}
即使我在视图中添加{{会话::put('data',true)}}{{会话::put('uid',10)}}打印后_r(会话::all())
Array
(
[_token] => EbF7RexCI97QM3jFUilWZsNIMiqyhdAcRcXUY8kB
[flash] => Array
(
[new] => Array
(
)
[old] => Array
(
[0] => data
[1] => uid
)
)
[data] => 1
[uid] => 10
)
with
方法向会话闪烁数据;这意味着数据将只对第一个请求可用,因此这是预期的行为。