The issue you're experiencing is likely due to the way you're using memcached to store user session data. Memcached is a distributed memory caching system, and it's not designed to handle session data that needs to be unique per user session. When you cache the user model in memcached, it doesn't differentiate between different sessions or browsers, which is why you're seeing the same user across different browsers.
To resolve this issue, you should use a session management system that is designed to handle per-user sessions. Here are a few steps you can take:
-
Use a Session Store: Instead of using memcached for user sessions, use a session store that is designed for this purpose. Common options include:
- Database-backed sessions: Store session data in your database.
- File-based sessions: Store session data in files on the server.
- Redis: A popular choice for session storage due to its speed and persistence.
-
Configure Your Application: If you're using a framework like Laravel, you can easily configure the session driver in the configuration file. For example, in Laravel, you can set the session driver in
config/session.php:'driver' => env('SESSION_DRIVER', 'file'),You can change
'file'to'database','redis', or another supported driver. -
Ensure Session Isolation: Make sure that each user session is isolated and not shared across different browsers or devices. This is typically handled by the session management system.
-
Test Across Browsers: After making these changes, test logging in with different users across different browsers to ensure that sessions are handled correctly and independently.
By using a proper session management system, you can ensure that each user's session is isolated and that logging in from different browsers will not interfere with each other.