Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lat4732's avatar
Level 12

Problem with logging in (Laravel Jetstream)

Hello everyone!

I have the following problem: Always when I try to log in, on the first attempt the page is just reloading without performing any action like showing up a message for wrong credentials or something like this. On the second attempt everything works fine. Any ideas?

P.S: I had done a topic some time ago for this problem, but I remember one of you telling me to die&dump when sending the request, but I don't know how to get to the login page controller to dd() it.

0 likes
31 replies
Sinnbeck's avatar

Does it make a difference if you refresh the page before you try to sign in?

lat4732's avatar
Level 12

Whats the point of asking questions directed to the problem if you don't continue your thoughts? Generally what is the point of this forum if no one is trying to help? I asked for help about this problem like 3 times now...

P.S: I got an answer from a guy in another community saying that I need to change the value of same_site in config/session.php from lax to null. I did, but the problem is still there. I've asked him what's the point of doing that but guess what - no answer. Same situation as here.

Sinnbeck's avatar

@crypt.001111101 You do realize that we are doing this in our spare time for free right? Personally I don't use Jetstream so I don't have any idea how that specific issue is happening. The same might be the case with others. Or they have just never had the same issue that you are experiencing.

Generally what is the point of this forum if no one is trying to help?

If you look at the amount of questions coming in and the answers given for free every day, I would indeed say that people are very much doing their best to help out.

You could help us to help you by making a small project on github with the problem. Then that would allow us to reproduce the error ourselves, and thereby see what is going wrong.

2 likes
lat4732's avatar
Level 12

@Sinnbeck I'm not trying to belittle the things you do for this community. It's just annoying how people are asking you questions directed to your problem like they care and after your answer - no one replies anymore. I need so badly a solution to this problem. Let's try to bone it. I just noticed that when I open a browser that never used before and log in - everything works fine. Even if I logout and login in the same account - again works fine. But when I try to login with another account - the problem appears. What is coming in my head is there is some misunderstading between the sessions.

Sinnbeck's avatar

@crypt.001111101 As I said. Feel free to post a link to a github repo with the issue, and I am sure we will have a easier time helping you

lat4732's avatar
Level 12

@Sinnbeck I wont be able to post a link with github repo for some reasons. Either help me up while we are talking for the problem or thanks to all for your time about this question and I'll search a solution somewhere else!

Sinnbeck's avatar

@crypt.001111101 Sorry but I have no clue what could be the cause. If it was my own project, I would set some breakpoints inside the login logic, and use xdebug to step through the code to see what is going wrong. Or manually check the session() when its working and when it isn't

lat4732's avatar
Level 12

@Sinnbeck How can I get access to the login method in the login controller? There is nothing like LoginController in app/Http/Controllers.

Sinnbeck's avatar

@crypt.001111101 As I said, I havent used it, so I dont know. But a quick look in the docs, show how you can easily extract the logic to a service provider, so you can handle it yourself.

https://jetstream.laravel.com/2.x/features/authentication.html#customizing-user-authentication

Otherwise, you could try and make brand new project with jetstream, and see if the issue is there as well. If not, you can compare your "broken" version with this new version

mabdullahsari's avatar

@crypt.001111101 Who the hell do you think you are? Where does this sassy entitlement come from that everyone must answer your question right after posting the question? Either patiently wait for someone knowledgable to reach out a hand or pipe down and go fix it yourself.

I've asked you a question to which you've provided an answer 1 week later, but now are complaining here that there is not enough engagement. Excuse me?

Learn how to ask your questions properly first with every bit of relevant context and try again.

Douche.

1 like
Snapey's avatar

What have you changed about the default Jetstream installation. What is out of the box works perfectly, however, if you have messed with middleware etc then maybe you have introduced an issue.

Sounds to me like you ARE ALREADY logged in (probably via the remember me token) and you are trying to login again.

Go into your browser development tools and delete the cookies then see what happens.

lat4732's avatar
Level 12

@Snapey Yes, there weren't problems after deleting the cookies. I've logged in immediately without problems.

Snapey's avatar

@crypt.001111101 ok, so logout. Can you login with the same credentials?

logout, can you login with different credentials?

lat4732's avatar
Level 12

@Snapey I was working on something. Sorry for my late answer. I can log with same credentials without problems. But if I try to login with different credentials first attempt is just refreshing the page.

Tray2's avatar

@crypt.001111101 Can you share your composer.json and composer.lock files and your packages.json and package-lock.json files?

Which browser are you using?

Which webserver?

Which version of php?

lat4732's avatar
Level 12

@tray2

  1. https://files.fm/u/3ap6vu6q7#/

  2. Mainly Mozilla, but I've tested it on much browsers and the problem is absolutely not from the browser.

  3. If you learn me how to check it I'll be able to tell you. At this point I don't know. I'm on local server (XAMPP).

  4. PHP 8.0.13

Tray2's avatar

@crypt.001111101 Apache then, the A in XAMPP is Apache.

php artisan -V vill give you the version of Laravel and for the rest of the files please put the contents as text in your issue and not as a external link to an image.

lat4732's avatar
Level 12

@Tray2 Laravel Framework 8.61.0. I've already put the contents as a reply and your website totally crazied out as the files content is a total lines of 35000 (BTW I think you should put a character limit on replies and threads at all). After that I deleted that reply and managed to upload them somewhere else (as files, not as images).

lat4732's avatar
Level 12

@Tray2 I was referring to the website as a whole and I accepted you as part of it as you're a Level 50 member.

Tray2's avatar

@crypt.001111101 We are not affiliated with Laracasts at all, we are just members of Laracasts and have no say in how the site works.

Have you tried doing a fresh install of Laravel and Jetstream?

lat4732's avatar
Level 12

@Tray2 No, I haven't. But I think if we don't find any other solution the fresh install and redesign from the beginning will be the real solution...

Tray2's avatar

@crypt.001111101 Try to do a fresh install and if that works without any hitch it's something you have added that causes the issue. The only way to solve this is to add them one by one until it breaks.

jlrdw's avatar

@crypt.001111101 setup the authentication just like it's originally setup "out of the box" In fact the only times I see these types of problems is when someone adds unneeded middleware that conflicts with a proper login / redirect.

So to troubleshoot, restore the "out of box" and do a step at a time until you hit the problem again, then you will know where it's happening.

Also use the network tab to check your request and response is correct as you troubleshoot.

But I can assure you, the scaffolded Auth works correctly with no problems when it hasn't been modified with some error code.

How can I get access to the login method in the login controller?

Did you read the fortify documentation: https://laravel.com/docs/8.x/fortify#installation

Next, publish Fortify's resources using the vendor:publish command:

php artisan vendor:publish --provider="Laravel\Fortify\FortifyServiceProvider"

This command will publish Fortify's actions to your app/Actions directory, which will be created if it does not exist. In addition, Fortify's configuration file and migrations will be published.

edit

Also once working, you don't have to do anything with middleware, rather, use authentication for login and use authorization to determine what the user with their role/s can or cannot do.

lat4732's avatar
lat4732
OP
Best Answer
Level 12

After many, many researches for this kind of problem I think I found my specific solution. I've actually built a route long time ago for logging out which had the following code:

Auth::logout();
return redirect()->route('site.home');

I have no idea why I've created and used this route at all. According to jetstream's core code and my understandings that's not how you fully logout a user and destroy session. But here's how:

    /**
     * Destroy an authenticated session.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Laravel\Fortify\Contracts\LogoutResponse
     */
    public function destroy(Request $request): LogoutResponse
    {
        $this->guard->logout();

        $request->session()->invalidate();

        $request->session()->regenerateToken();

        return app(LogoutResponse::class);
    }

I've tested right now everything works fine. If any problems appear again I'll reply back. Thanks to everyone!

Please or to participate in this conversation.