简体   繁体   English

如何重定向到另一个页面

[英]How to redirect to another page laravel

I simply wrote few lines on the top of the page that if the session is not set then it should redirect to another page but it's not working it show the white screen and doesn't redirect to another page Here is the code. 我只是在页面顶部写了几行,如果未设置会话,则应将其重定向到另一个页面,但它不起作用,它将显示白屏,并且不会重定向到另一个页面。这是代码。

session_start();
include('includedb2.php');
if(! isset($_SESSION['login_user']))
{
  return Redirect::to('front');
  exit;
}

I added it on the top of the page but it's not working 我将其添加到页面顶部,但无法正常工作

I find that isset isn't optimal when checking if a key in an array exists. 我发现检查数组中的键是否存在时isset并不是最佳的。 Instead, why not use array_key_exists to check if login_user is in $_SESSION instead? 相反,为什么不使用array_key_exists来检查login_user是否在$_SESSION

Additionally, your redirect syntax seems a little different from what I saw in Laravel's redirect documentation . 另外,您的重定向语法似乎与我在Laravel的重定向文档中看到的有所不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM