Dolibarr/dolibarr · warning

You are logged with user

Error message

You are logged with user "${_SESSION[dol_login]}" and only administrator users (${MAIN_ONLY_LOGIN_ALLOWED}) is allowed to connect for the moment.

What it means

This message complements the previous one: a session exists and dol_login is set, but that login is NOT in the MAIN_ONLY_LOGIN_ALLOWED list. Dolibarr refuses service, tells the user which account they are logged in with, and offers a logout link to switch to an allowed admin account.

Solutions

  1. Click the provided logout link and re-login as an admin listed in MAIN_ONLY_LOGIN_ALLOWED
  2. Have an admin remove/extend MAIN_ONLY_LOGIN_ALLOWED to include the needed users
  3. Clear the session cookie if the session is stale
Defensive patterns

Strategy: retry

Prevention

When it happens

Trigger: MAIN_ONLY_LOGIN_ALLOWED='admin'; a normal user with an active session browses any page while the restriction is active.

Common situations: Non-admin users keeping open browser sessions during a maintenance window; stale sessions after the admin narrowed MAIN_ONLY_LOGIN_ALLOWED.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of Dolibarr/dolibarr@598aa4bdad (2026-09-14). Data as JSON: /api/errors/be7b3d801226587d. Report an issue: GitHub.

Appendix: source

Thrown at htdocs/main.inc.php:193

// If software has been locked. Only login getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED') is allowed.
if (getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')) {
	$ok = 0;
	if ((!session_id() || !isset($_SESSION["dol_login"])) && !isset($_POST["username"]) && !empty($_SERVER["GATEWAY_INTERFACE"])) {
		$ok = 1; // We let working pages if not logged and inside a web browser (login form, to allow login by admin)
	} elseif (isset($_POST["username"]) && in_array($_POST["username"], explode(';', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')))) {
		$ok = 1; // We let working pages that is a login submission (login submit, to allow login by admin)
	} elseif (defined('NOREQUIREDB')) {
		$ok = 1; // We let working pages that don't need database access (xxx.css.php)
	} elseif (defined('EVEN_IF_ONLY_LOGIN_ALLOWED')) {
		$ok = 1; // We let working pages that ask to work even if only login enabled (logout.php)
	} elseif (session_id() && isset($_SESSION["dol_login"]) && in_array($_SESSION["dol_login"], explode(';', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')))) {
		$ok = 1; // We let working if user is allowed admin
	}
	if (!$ok) {
		if (session_id() && isset($_SESSION["dol_login"]) && !in_array($_SESSION["dol_login"], explode(';', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')))) {
			print 'Sorry, your application is offline.'."\n";
			print 'You are logged with user "'.$_SESSION["dol_login"].'" and only administrator users (' . str_replace(';', ', ', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')).') is allowed to connect for the moment.'."\n";
			$nexturl = dolBuildUrl(DOL_URL_ROOT . '/user/logout.php', [], true);
			print 'Please try later or <a href="'.$nexturl.'">click here to disconnect and change login user</a>...'."\n";
		} else {
			print 'Sorry, your application is offline. Only administrator users (' . str_replace(';', ', ', getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')).') is allowed to connect for the moment.'."\n";
			$nexturl = dolBuildUrl(DOL_URL_ROOT . '/');
			print 'Please try later or <a href="'.$nexturl.'">click here to change login user</a>...'."\n";
		}
		exit;
	}
}


// Activate end of page function
register_shutdown_function('dol_shutdown');

// Load debugbar
if (isModEnabled('debugbar') && !GETPOST('dol_use_jmobile') && empty($_SESSION['dol_use_jmobile'])) {
	global $debugbar;

View on GitHub (pinned to 598aa4bdad)