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

MDelisle's avatar

Not able to login under 2 different accounts

Hi,

I was building a project doing initially the first steps to build it (model, factory, migration,etc) including to 2 new users ([email protected] with "TextUser" as name and [email protected] with "Mario" as name). The initial installation was with Laravel Breeze with Vue and Inertia and finally using SQlite as database. After to complete the migration to get the tables that I need and generate those 2 users account, I get this issue when I come to login the second account (the first account on port 8000 and the second account on port 8001) the second account give me the name of the first account so I get 2 pages set with the same name ("TestUser") and not able to select anything on the second page.

If I restart the second page, with the second name, it opens under the second name but still not able to select anything (select Profile or logout per example).

I need some advise here. Do I have to do anything else ot get those 2 accounts added (under DatabaseSeeder.php) to get them completely independent from the other?

Thanks for your attention

Mario

0 likes
5 replies
LaryAI's avatar
Level 58

The issue you're experiencing seems to be related to session management and how Laravel handles authentication across different browser sessions. When you run two instances of your application on different ports, they might be sharing the same session storage, which can cause conflicts.

Here are a few steps you can take to resolve this issue:

  1. Use Different Browsers or Incognito Mode:

    • Try logging into one account using a regular browser window and the other account using an incognito window or a different browser. This ensures that each session is isolated.
  2. Configure Session Storage:

    • Ensure that your session storage is correctly configured. If you're using file-based sessions, they might be shared across different instances. Consider using a different session driver like database or redis if available.
  3. Check Session Domain Configuration:

    • In your config/session.php file, ensure that the domain configuration is set correctly. If you're running on localhost, you might not need to set this, but if you have a specific domain, make sure it's configured properly.
  4. Clear Sessions and Cache:

    • Clear any existing sessions and cache to ensure there are no stale sessions causing conflicts. You can do this by running:
      php artisan cache:clear
      php artisan config:clear
      php artisan session:clear
      
  5. Check for Middleware Issues:

    • Ensure that your middleware stack is correctly configured and that there are no custom middlewares interfering with session handling.
  6. DatabaseSeeder Configuration:

    • Double-check your DatabaseSeeder.php to ensure that the users are being created with unique identifiers and that there are no issues with how they are seeded.

Here's a basic example of how you might seed users:

// DatabaseSeeder.php
public function run()
{
    \App\Models\User::factory()->create([
        'name' => 'TestUser',
        'email' => '[email protected]',
        'password' => bcrypt('password'), // Ensure passwords are hashed
    ]);

    \App\Models\User::factory()->create([
        'name' => 'Mario',
        'email' => '[email protected]',
        'password' => bcrypt('password'), // Ensure passwords are hashed
    ]);
}

By following these steps, you should be able to resolve the issue of logging in with two different accounts on different ports. If the problem persists, consider checking the Laravel logs for any errors or additional clues.

Batman55's avatar
Batman55
Best Answer
Level 32

@laryai explained this very well. It's the way sessions work by default.

His first is really what your wanting to do in most cases.

Use Different Browsers or Incognito Mode:

    Try logging into one account using a regular browser window and the other account using an incognito window or a different browser. This ensures that each session is isolated.

MDelisle's avatar

@Batman55 Just try using Chrome on one and Safari on the other and this work..

Snapey's avatar

Why / how do you have a web server running on two different ports ?

MDelisle's avatar

@Snapey Hi Snapey Actually, I am still starting my development for the programmation using Warp and when I execute "php artisan serve" from Warp, it select automatically my default port (8000) and when I start a second session under another tab of Warp, it automatically define the next port available.

Please or to participate in this conversation.