Server
The Remote Server works alongside the simulator to manage participants and store study data. It provides two functions: authorization, which verifies participant identities before they can access your study, and data collection, which stores the data generated during each session.
This guide explains how the server works, describes the files it needs and the role of each one, and walks you through deploying it.
Server authorization
You can set up a simple authorization layer for the simulator. It ensures that only valid participants can run the study and that each participant receives a unique Subject ID.
Each participant identifies themselves to the server with a Participant ID (such as a Prolific ID or an mTurk Worker ID). The server responds with a unique Subject ID, which the simulator uses to track that participant during the session.
How authorization works
When the simulator starts, it sends the Participant ID to the server as the search field of a POST request.
- The simulator (client) sends the Participant ID to the server.
- The server checks whether this Participant ID has already been used:
- If the Participant ID is new, the server records it and returns a Subject ID as JSON, for example
{"subjectID": 0}. - If the Participant ID has already been used, the server rejects the request with HTTP status
409. If the Participant ID is missing, it returns400.
- If the Participant ID is new, the server records it and returns a Subject ID as JSON, for example
mTurkServer.phpuses simple file storage and does not lock the files. If two requests arrive at almost exactly the same time, there is a small chance that both pass validation with the same Participant ID or receive the same Subject ID. This is unlikely, but possible.- This authorization is intended as a lightweight safeguard, not a highly secure solution.
For information on configuring server authorization, see Server Authorization settings.
Data collection
The Remote Server also handles data collection. The simulator uploads collected data to the server's senddata.php file, which saves each upload as a file in the data/map00/ folder next to senddata.php (the simulator always sends map00 as the folder name). The file is named [userid]_[original file name].gz.
For details on the data format, storage location, and how to retrieve the data, see the Data Collection Guide.
Deployment
The files needed to deploy the Remote Server are included in the simulator repository, in the server folder at the root of the repository.
Contents of the server folder
Local testing
Install PHP and make sure the php command is available in your terminal (check with php --version). The Windows helper is a command script, not a separate application.
From a terminal in the simulator's server folder, start it with:
.\Start_local_server.cmd
The script serves its own folder at http://localhost:8000, even when launched from another directory. Existing participant IDs, the counter, and uploaded data are preserved. If missing, mturkworkers.txt is created empty and count.txt is initialized to 0. Keep the terminal open while testing; press Ctrl+C to stop the server.
For local testing, use these simulator settings:
- Server Authorization > Server Address:
http://localhost:8000/mTurkServer.php - Data Collection > Server Address:
http://localhost:8000/senddata.php
To clear authorization data, stop the server first, then run:
.\Start_local_server.cmd --reset
This clears all recorded Participant IDs and sets the Subject ID counter to 0, then exits without starting the server. It does not delete uploads under data/. Because Subject IDs are reused after a reset, archive earlier uploads or use a separate test copy to avoid mixing sessions or overwriting files with matching names.
On Windows, macOS, or Linux, you can also start PHP directly from the server folder:
php -S localhost:8000
This command does not initialize or reset authorization files; ensure mturkworkers.txt and count.txt already exist.
PHP's built-in server is for local development, not public deployment. Use a separate copy of the server folder for testing so study data remains untouched. localhost refers to the computer running the simulator; these URLs are not remote participant endpoints.
Public deployment
To deploy the server:
- Copy the contents of the
serverfolder to a web server with PHP that is publicly reachable by URL. - Make sure the web server has read and write permissions for
count.txtandmturkworkers.txt(file names are case-sensitive on most web servers), and permission to create thedata/folder next tosenddata.php. Authorization and data collection do not work without these permissions. - In Project Settings > mobisim > Server Authorization, set the Server Address to the URL of
mTurkServer.phpon your server. - In Project Settings > mobisim > Data Collection, set the Server Address to the URL of
senddata.phpon your server.