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:
-
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.
-
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
databaseorredisif available.
- 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
-
Check Session Domain Configuration:
- In your
config/session.phpfile, ensure that thedomainconfiguration 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.
- In your
-
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
- Clear any existing sessions and cache to ensure there are no stale sessions causing conflicts. You can do this by running:
-
Check for Middleware Issues:
- Ensure that your middleware stack is correctly configured and that there are no custom middlewares interfering with session handling.
-
DatabaseSeeder Configuration:
- Double-check your
DatabaseSeeder.phpto ensure that the users are being created with unique identifiers and that there are no issues with how they are seeded.
- Double-check your
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.