// and it's valid against our configured locales, we require the session
// to store this, even if that means starting an anonymous session.
$session->set('lcMessages', $chosenLocale);
+
+ // Clear menu cache if we've changed locale.
+ CRM_Core_BAO_Navigation::resetNavigation();
}
/*
\Civi\Core\Container::boot($loadFromDB);
if ($loadFromDB && self::$_singleton->dsn) {
$domain = \CRM_Core_BAO_Domain::getDomain();
+ if (CIVICRM_UF === 'Standalone') {
+ // Standalone's session cannot be initialized until CiviCRM is booted,
+ // since it is defined in an extension, and we need the session
+ // initialized before calling applyLocale.
+ \CRM_Core_Session::singleton()->initialize();
+ }
\CRM_Core_BAO_ConfigSetting::applyLocale(\Civi::settings($domain->id), $domain->locales);
unset($errorScope);
return !class_exists(\Civi\Standalone\Security::class);
}
- public function initialize() {
- parent::initialize();
- // Initialize the session if it looks like there might be one.
- // Case 1: user sends no session cookie: do NOT start the session. May be anon access that does not require session data. Good for caching.
- // Case 2: user sends a session cookie: start the session, so we can access data like lcMessages for localization (which occurs early in the boot process).
- // Case 3: user sends a session cookie but it's invalid: start the session, it will be empty and a new cookie will be sent.
- if (isset($_COOKIE['PHPSESSID'])) {
- // Note: passing $isRead = FALSE in the arguments will cause the session to be started.
- CRM_Core_Session::singleton()->initialize(FALSE);
- }
- }
-
/**
* @inheritdoc
*/
$session_handler = new SessionHandler();
session_set_save_handler($session_handler);
- $session_max_lifetime = Civi::settings()->get('standaloneusers_session_max_lifetime');
+ $session_max_lifetime = Civi::settings()->get('standaloneusers_session_max_lifetime') ?? 1440;
session_start([
'cookie_httponly' => 1,
function invoke() {
$requestUri = $_SERVER['REQUEST_URI'] ?? '';
- // Required so that the userID is set before generating the menu
- \CRM_Core_Session::singleton()->initialize();
// Add CSS, JS, etc. that is required for this page.
\CRM_Core_Resources::singleton()->addCoreResources();
$parts = explode('?', $requestUri);