@rootMar 19.2018 — #You don't use JavaScript to control logins.
PHP on the server and a database and use of sessions makes this possible by only allowing the session to run for the time period that the session variable is considered live, this depends on the setting.
You would also need admin pages for allowing an admin to add or remove people to the system, people can login or register via the form.