2 namespace wcf\data\session\virtual
;
3 use wcf\data\DatabaseObject
;
8 * Virtual Sessions extend the original session system with a transparent layer.
9 * It's only purpose is to enforce session validation based on IP address and/or user agent.
11 * The legacy session system does not allow the same user being logged-in more than once
12 * and the same is true for WCF 2.1 unless we break most parts of the API.
13 * In order to solve this, we do allow multiple clients to share the exact same session
14 * among them, while the individual clients are tracked within wcf1_session_virtual.
16 * @author Alexander Ebert
17 * @copyright 2001-2014 WoltLab GmbH
18 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
19 * @package com.woltlab.wcf
20 * @subpackage data.session.virtual
21 * @category Community Framework
23 class SessionVirtual
extends DatabaseObject
{
25 * @see \wcf\data\DatabaseObject::$databaseTableName
27 protected static $databaseTableName = 'session_virtual';
30 * @see \wcf\data\DatabaseObject::$databaseTableIndexName
32 protected static $databaseTableIndexName = 'virtualSessionID';
35 * Returns the active virtual session object or null.
37 * @param string $sessionID
38 * @return \wcf\data\session\virtual\SessionVirtual
40 public static function getExistingSession($sessionID) {
42 FROM ".static::getDatabaseTableName()."
46 $statement = WCF
::getDB()->prepareStatement($sql);
47 $statement->execute(array(
49 UserUtil
::getIpAddress(),
50 UserUtil
::getUserAgent()
53 return $statement->fetchObject(__CLASS__
);
57 * Returns the number of virtual sessions associated with the given session id.
59 * @param string $sessionID
62 public static function countVirtualSessions($sessionID) {
63 $sql = "SELECT COUNT(*) AS count
64 FROM ".static::getDatabaseTableName()."
66 $statement = WCF
::getDB()->prepareStatement($sql);
67 $statement->execute(array($sessionID));
68 $row = $statement->fetchArray();