1
我在CompanyController->create()
重定向:laravel 4 - 子域 - 會話重定向後丟失::行動()
class CompanyController extends \BaseController {
...
public function index(){
echo var_dump(Session::get('err'));
}
...
public function create()
{
if($validator->passes()){
$this->setError("no errors");
}else{
$this->setError("Some errors occurred: ");
foreach($validator->messages()->all() as $msg)
$this->setError($msg);
}
return Redirect::action('[email protected]');
}
}
我BaseController類看起來是這樣的:
class BaseController extends Controller {
private $errors = array();
protected $view_params = array();
function __construct() {
if(Session::has('err')){
$this->errors = Session::get('err');
$this->view_params['err'] = $this->errors;
}
}
...
protected function setError($str){
if(!isset($this->view_params['err']) || $this->view_params['err']==null)
$this->view_params['err']=array();
if(!isset($this->errors) || $this->errors==null)
$this->errors=array();
array_push($this->view_params['err'],$str);
array_push($this->errors,$str);
Session::put('err',$this->errors);
}
protected function getErrors(){
return $this->errors;
}
}
的CompanyController->index()
功能總是顯示NULL
。爲什麼?
編輯 我的會話設置:
'driver' => 'native',
'lifetime' => 0,
'domain' => '.domain.com',
沒有任何自定義會話設置嘗試一次(只使用默認值)。它工作嗎? –