Hello,

I wonder why I need to press F5 before entering the admin page after login.

home_admin.blade.php

<form class="navbar-form navbar-right" id="form_login" method="post" style="margin-top: 0;"
                  action="{{ url('/auth/login') }}">
                <input type="hidden" id="_token" name="_token" value="{{ csrf_token() }}">

                <div class="form-group">
                    <span class="control-header">Email</span>
                    <span><input type="text" name="email" placeholder="Email" required
                                 class="form-control"/></span>
                </div>
                <div class="form-group">
                    <span class="control-header">Password</span>
                    <span><input type="password" name="password" placeholder="Password" required
                                 class="form-control"/></span>
                    <input type="hidden" name="domain" required value="{{$domain}}"/>
                </div>
                <div class="form-group">
                    <h3 style="margin-top: 2px;">
                        <button type="submit" id="btn_login"><span class="glyphicon glyphicon-log-in"
                                                                   aria-hidden="true"></span> login
                        </button>
                    </h3>
                </div>
                <br>
                <a href="#" data-toggle="modal" data-target="#forgot_password"
                   style="margin-top: -7px;float: right;margin-right: 90px;font-size: 10px;color: white;">Forgot
                    Password?</a>
            </form>

routes.php

Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
'home'=>'HomeController',
'member'=>'MemberController',
'mail'=>'MailController',
'social'=>'SocialController',
'ajax'=>'AjaxController',
'api'=>'ApiController',
'timeline'=>'TimelineController',
'setting'=>'SettingController',
 //    'ecommerce'=>'EcommerceController',
'test'=>'TestController',
 ]);

AuthController.php

class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/

use AuthenticatesAndRegistersUsers, ThrottlesLogins;

/**
 * Create a new authentication controller instance.
 *
 * @return void
 */
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}

/**
 * Get a validator for an incoming registration request.
 *
 * @param  array  $data
 * @return \Illuminate\Contracts\Validation\Validator
 */
protected function validator(array $data)
{
return Validator::make($data, [
    'name' => 'required|max:255',
    'email' => 'required|email|max:255|unique:users',
    'password' => 'required|confirmed|min:6',
]);
}

/**
 * Create a new user instance after a valid registration.
 *
 * @param  array  $data
 * @return User
 */

protected function create(array $data)
{
return User::create([
    'name' => $data['name'],
    'email' => $data['email'],
    'password' => bcrypt($data['password']),
]);
}
}

PasswordController.php

 class PasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/

use ResetsPasswords;

/**
 * Create a new password controller instance.
 *
 * @return void
 */
public function __construct()
{
    $this->middleware('guest');
}

}

I also wonder if it's using javascript since I cannot find the form_login (id="form_login") anywhere in the file.

Dani AI

Generated

This symptom (you can log in but only see the admin view after pressing F5) almost always means the browser is showing a cached/old page or the session cookie that marks you as “logged in” isn’t being sent on the first redirected request. For : pressing F5 forces a fresh GET where the cookie is applied, which is why the admin UI appears only after the refresh.

Quick, focused checks to narrow it down:

  • Use the browser DevTools Network tab when you submit the login form. Look at the POST /auth/login response: is it a 302 redirect? Does the response include a Set-Cookie header for the Laravel session cookie (name like laravel_session or whatever you set)? Then check the subsequent GET to the admin page — does that request include the Cookie header?
  • Try in a private window or another browser. If it works there, it’s a client-side cache/cookie issue.
  • Inspect server-side: check config/session.php (and your .env SESSION_DRIVER/SESSION_DOMAIN/SESSION_SECURE_COOKIE), ensure storage/framework/sessions is writable, and scan storage/logs/laravel.log for session or cookie errors.

Possible causes and quick remedies:

  • Cookie domain/secure mismatch (www vs non-www, HTTP vs HTTPS) — make SESSION_DOMAIN match the site and SESSION_SECURE_COOKIE only true when using HTTPS.
  • Server session not persisting (permissions or wrong driver) — switch to file temporarily and confirm sessions get written.
  • Client caching — add no-cache headers to pages that change with auth state or ensure your login response redirects correctly instead of returning an HTML fragment.

If can post the Network request/response headers (POST /auth/login and the following GET) or a snippet of the login controller’s post-auth redirect, that will make it possible to give the exact fix. As asked, say whether you see a 302, a 200 with the old page, or any errors — include the headers if you can.

What happens right after you login before entering the admin page?
Does it show an auth error, a PHP error, Laravel error, blank page?

You need to provide more details with your questions/problems.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.