如果会话存在,我想让视图无法加载,并将其重定向到其他视图。例如,如果用户已登录(存在会话(,则登录页面视图应重定向到主页面。目前我的代码是这样的。此代码可以检测会话,但重定向不起作用(空白页(。
<?php if (Session::has('sessionId')){return redirect('/front')} ?>
<!DOCTYPE html>
<html>
</html>
试试这个组织导入:
use IlluminateSupportFacadesAuth;
您在控制器中的操作
public function actionName() //your action name from routes`{
if (Auth::check()) {
return Redirect::to('/front'));
}}`