Managing session details for multiple instances of a Play framework server on the same machine

StackOverflow https://stackoverflow.com/questions/9202794

Question

I've been working on a Play framework social networking application, and I've come across a small problem when actually attempting to test the application. I'm using multiple instances of the same application running on different ports, but the session information from one is being overwritten by the other.

For example, should I create an account for Bob on one instance of the session and then load the homepage on the second session (on a completely different port), I find that Bob is already logged in. Creating an account for Alice causes Bob to lose all his session data in favour of Alice's new data.

The code that I have is quite simple:

    static boolean authenticate(String username, String password) {
        User u = User.connect(username,password);
        return (u != null);
    }

One of the apps is running on port 9001 and the other on port 9002.

Does anyone have any idea how I can work around this issue and test multiple user accounts from the same computer?

Était-ce utile?

La solution

Think about the following points:

  1. Are you testing using the same browser instance? What if you login to different play instance using different browser?

  2. What's the motivation to start 2 play instance? Are you trying to setup a load balance or fault tolerant solution or you actually need to 2 different server? For the latter case, you should generate different secret seeds using "play secret"

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top