jeudi 1 février 2018

Laravel view @include auto logout when refresh

I am using Laravel 5.5 with mysql database, session storing in database.

@Problem : Whenever I refresh or go into another page, it will log me out and redirect me back to the login page.

@Cause : After debugging, I found out whenever I @include a view top.blade.php inside my view template named master.blade.php, when I refresh the page, it will auto log me out and killing off the session.

The codes inside top.blade.php :

<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">

  <!-- Mobile Menu -->
  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
    <span class="icon-bar"></span>
  </button>

  <!-- Header Icon -->
    <a  href="">
      <img class="navbar-brand" src="" alt="Little Project">
    </a>

    <!-- Message Of The Day -->
    <div class="navbar-text visible-xs"><p>Little Project</p></div>
     <!-- to check the user info if it retains -->
</div>



<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

<!--Right side of the NavBar -->
  <ul class="nav navbar-nav navbar-right">
      @guest
        <li><a href="">Login</a></li>
        <li><a href="">Register</a></li>
      @else
        <li><a href="">Demo</a></li>
        <li><a href="">Logout</a></li>
      @endguest
  </ul>

</div><!-- /.navbar-collapse -->

While the master.blade.php file is

<!DOCTYPE html>
<html lang="">
<head>

<!--meta header-->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="">

    <!-- Styles -->
    <link href="" rel="stylesheet">

    <!-- Title -->
    <title>Little Project</title>
</head>
<body>
    @include('constants.top')
    <div class="container">
      <!-- Contents -->
      @yield('content')

    </div>


    <!-- Scripts -->
    <script src=""></script>
</body>

</html>

Upon login, successful display of information at both top.blade.php and master.blade.php to check the User's login information

However when refresh, it will destroy all sessions as long as I @include top.blade.php



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2FyyFy2
via IFTTT

Aucun commentaire:

Enregistrer un commentaire