- client_id) : ?>
+ client_id === null) : ?>
+
+ client_id) : ?>
diff --git a/administrator/modules/mod_status/mod_status.php b/administrator/modules/mod_status/mod_status.php
index 0df3814f6254a..5f8ab5a48f138 100644
--- a/administrator/modules/mod_status/mod_status.php
+++ b/administrator/modules/mod_status/mod_status.php
@@ -24,14 +24,19 @@
$db->setQuery($query);
$unread = (int) $db->loadResult();
-// Get the number of backend logged in users.
-$query->clear()
- ->select('COUNT(session_id)')
- ->from('#__session')
- ->where('guest = 0 AND client_id = 1');
+$count = 0;
-$db->setQuery($query);
-$count = (int) $db->loadResult();
+// Get the number of backend logged in users if shared sessions is not enabled.
+if (!$config->get('shared_session', '0'))
+{
+ $query->clear()
+ ->select('COUNT(session_id)')
+ ->from('#__session')
+ ->where('guest = 0 AND client_id = 1');
+
+ $db->setQuery($query);
+ $count = (int) $db->loadResult();
+}
// Set the inbox link.
if ($input->getBool('hidemainmenu'))
@@ -53,13 +58,32 @@
$inboxClass = 'no-unread-messages';
}
-// Get the number of frontend logged in users.
-$query->clear()
- ->select('COUNT(session_id)')
- ->from('#__session')
- ->where('guest = 0 AND client_id = 0');
+$online_num = 0;
-$db->setQuery($query);
-$online_num = (int) $db->loadResult();
+// Get the number of frontend logged in users if shared sessions is not enabled.
+if (!$config->get('shared_session', '0'))
+{
+ $query->clear()
+ ->select('COUNT(session_id)')
+ ->from('#__session')
+ ->where('guest = 0 AND client_id = 0');
+
+ $db->setQuery($query);
+ $online_num = (int) $db->loadResult();
+}
+
+$total_users = 0;
+
+// Get the number of logged in users if shared sessions is enabled.
+if ($config->get('shared_session', '0'))
+{
+ $query->clear()
+ ->select('COUNT(session_id)')
+ ->from('#__session')
+ ->where('guest = 0');
+
+ $db->setQuery($query);
+ $total_users = (int) $db->loadResult();
+}
require JModuleHelper::getLayoutPath('mod_status', $params->get('layout', 'default'));
diff --git a/administrator/modules/mod_status/tmpl/default.php b/administrator/modules/mod_status/tmpl/default.php
index 43c3ca6d94a4f..1dfa42fb48eab 100644
--- a/administrator/modules/mod_status/tmpl/default.php
+++ b/administrator/modules/mod_status/tmpl/default.php
@@ -39,24 +39,40 @@
. '';
}
-// Print the frontend logged in users.
-if ($params->get('show_loggedin_users', 1))
+// Print logged in user count based on the shared session state
+if (JFactory::getConfig()->get('shared_session', '0'))
{
- $output[] = ''
- . '' . $online_num . ''
- . JText::plural('MOD_STATUS_USERS', $online_num)
- . ''
- . '
';
+ // Print the frontend logged in users.
+ if ($params->get('show_loggedin_users', 1))
+ {
+ $output[] = ''
+ . '' . $total_users . ''
+ . JText::plural('MOD_STATUS_TOTAL_USERS', $total_users)
+ . ''
+ . '
';
+ }
}
-
-// Print the backend logged in users.
-if ($params->get('show_loggedin_users_admin', 1))
+else
{
- $output[] = ''
- . '' . $count . ''
- . JText::plural('MOD_STATUS_BACKEND_USERS', $count)
- . ''
- . '
';
+ // Print the frontend logged in users.
+ if ($params->get('show_loggedin_users', 1))
+ {
+ $output[] = ''
+ . '' . $online_num . ''
+ . JText::plural('MOD_STATUS_USERS', $online_num)
+ . ''
+ . '
';
+ }
+
+ // Print the backend logged in users.
+ if ($params->get('show_loggedin_users_admin', 1))
+ {
+ $output[] = ''
+ . '' . $count . ''
+ . JText::plural('MOD_STATUS_BACKEND_USERS', $count)
+ . ''
+ . '
';
+ }
}
// Print the inbox message.
diff --git a/installation/model/configuration.php b/installation/model/configuration.php
index 535d2a89c567e..83ba3390ece6e 100644
--- a/installation/model/configuration.php
+++ b/installation/model/configuration.php
@@ -144,6 +144,7 @@ public function createConfiguration($options)
// Session setting.
$registry->set('lifetime', 15);
$registry->set('session_handler', 'database');
+ $registry->set('shared_session', 0);
// Generate the configuration class string buffer.
$buffer = $registry->toString('PHP', array('class' => 'JConfig', 'closingtag' => false));
diff --git a/installation/sql/mysql/joomla.sql b/installation/sql/mysql/joomla.sql
index c6adcd82122ac..57a97f4883e98 100644
--- a/installation/sql/mysql/joomla.sql
+++ b/installation/sql/mysql/joomla.sql
@@ -1561,7 +1561,7 @@ CREATE TABLE IF NOT EXISTS `#__schemas` (
CREATE TABLE IF NOT EXISTS `#__session` (
`session_id` varchar(191) NOT NULL DEFAULT '',
- `client_id` tinyint(3) unsigned NOT NULL DEFAULT 0,
+ `client_id` tinyint(3) unsigned DEFAULT NULL,
`guest` tinyint(4) unsigned DEFAULT 1,
`time` varchar(14) DEFAULT '',
`data` mediumtext,
diff --git a/installation/sql/postgresql/joomla.sql b/installation/sql/postgresql/joomla.sql
index ff855aaeb27b6..2e14b881555f8 100644
--- a/installation/sql/postgresql/joomla.sql
+++ b/installation/sql/postgresql/joomla.sql
@@ -1496,7 +1496,7 @@ CREATE TABLE "#__schemas" (
--
CREATE TABLE "#__session" (
"session_id" varchar(200) DEFAULT '' NOT NULL,
- "client_id" smallint DEFAULT 0 NOT NULL,
+ "client_id" smallint DEFAULT NULL,
"guest" smallint DEFAULT 1,
"time" varchar(14) DEFAULT '',
"data" text,
diff --git a/installation/sql/sqlazure/joomla.sql b/installation/sql/sqlazure/joomla.sql
index 8ec57921863f4..9bb565045d3f8 100644
--- a/installation/sql/sqlazure/joomla.sql
+++ b/installation/sql/sqlazure/joomla.sql
@@ -2516,7 +2516,7 @@ SET QUOTED_IDENTIFIER ON;
CREATE TABLE [#__session](
[session_id] [nvarchar](200) NOT NULL DEFAULT '',
- [client_id] [tinyint] NOT NULL DEFAULT 0,
+ [client_id] [tinyint] DEFAULT NULL,
[guest] [tinyint] NULL DEFAULT 1,
[time] [nvarchar](14) NULL DEFAULT '',
[data] [nvarchar](max) NULL,
diff --git a/libraries/cms/application/cms.php b/libraries/cms/application/cms.php
index d886c21fe8fe0..2527b2af6d9e8 100644
--- a/libraries/cms/application/cms.php
+++ b/libraries/cms/application/cms.php
@@ -184,7 +184,6 @@ public function checkSession()
$columns = array(
$db->quoteName('session_id'),
- $db->quoteName('client_id'),
$db->quoteName('guest'),
$db->quoteName('time'),
$db->quoteName('userid'),
@@ -193,13 +192,18 @@ public function checkSession()
$values = array(
$db->quote($session->getId()),
- (int) $this->getClientId(),
(int) $user->guest,
$db->quote((int) $time),
(int) $user->id,
$db->quote($user->username),
);
+ if (!$this->get('shared_session', '0'))
+ {
+ $columns[] = $db->quoteName('client_id');
+ $values[] = (int) $this->getClientId();
+ }
+
$query->insert($db->quoteName('#__session'))
->columns($columns)
->values(implode(', ', $values));
diff --git a/modules/mod_whosonline/helper.php b/modules/mod_whosonline/helper.php
index 5645347622e06..d409a10520606 100644
--- a/modules/mod_whosonline/helper.php
+++ b/modules/mod_whosonline/helper.php
@@ -32,10 +32,12 @@ public static function getOnlineCount()
$user_array = 0;
$guest_array = 0;
+ $whereCondition = JFactory::getConfig()->get('shared_session', '0') ? 'IS NULL' : '= 0';
+
$query = $db->getQuery(true)
->select('guest, client_id')
->from('#__session')
- ->where('client_id = 0');
+ ->where('client_id ' . $whereCondition);
$db->setQuery($query);
try
@@ -83,12 +85,14 @@ public static function getOnlineCount()
**/
public static function getOnlineUserNames($params)
{
+ $whereCondition = JFactory::getConfig()->get('shared_session', '0') ? 'IS NULL' : '= 0';
+
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName(array('a.username', 'a.userid', 'a.client_id')))
->from('#__session AS a')
->where($db->quoteName('a.userid') . ' != 0')
- ->where($db->quoteName('a.client_id') . ' = 0')
+ ->where($db->quoteName('a.client_id') . ' ' . $whereCondition)
->group($db->quoteName(array('a.username', 'a.userid', 'a.client_id')));
$user = JFactory::getUser();
diff --git a/plugins/user/joomla/joomla.php b/plugins/user/joomla/joomla.php
index 3ea31c7c49bb3..6d4c0a88c4bae 100644
--- a/plugins/user/joomla/joomla.php
+++ b/plugins/user/joomla/joomla.php
@@ -271,8 +271,10 @@ public function onUserLogout($user, $options = array())
return true;
}
+ $sharedSessions = $this->app->get('shared_session', '0');
+
// Check to see if we're deleting the current session
- if ($my->id == $user['id'] && $options['clientid'] == $this->app->getClientId())
+ if ($my->id == $user['id'] && (!$sharedSessions && $options['clientid'] == $this->app->getClientId()))
{
// Hit the user last visit field
$my->setLastVisit();
@@ -288,8 +290,12 @@ public function onUserLogout($user, $options = array())
{
$query = $this->db->getQuery(true)
->delete($this->db->quoteName('#__session'))
- ->where($this->db->quoteName('userid') . ' = ' . (int) $user['id'])
- ->where($this->db->quoteName('client_id') . ' = ' . (int) $options['clientid']);
+ ->where($this->db->quoteName('userid') . ' = ' . (int) $user['id']);
+
+ if (!$sharedSessions)
+ {
+ $query->where($this->db->quoteName('client_id') . ' = ' . (int) $options['clientid']);
+ }
try
{