original_string: public function checkSession()
  	{
  		$db = JFactory::getDbo();
  		$session = JFactory::getSession();
  		$user = JFactory::getUser();
  
  		$query = $db->getQuery(true)
  			->select($db->quoteName('session_id'))
  			->from($db->quoteName('#__users_sessions'))
  			->where($db->quoteName('session_id') . ' = ' . $db->quote($session->getId()));
  
  		$db->setQuery($query, 0, 1);
  		$exists = $db->loadResult();
  
  		// If the session record doesn't exist initialise it.
  		if (!$exists)
  		{
  			$query->clear();
  
  			if ($session->isNew())
  			{
  				$query->insert($db->quoteName('#__users_sessions'))
  					->columns($db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('time'))
  					->values($db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . $db->quote((int) time()));
  				$db->setQuery($query);
  			}
  			else
  			{
  				$query->insert($db->quoteName('#__users_sessions'))
  					->columns(
  						$db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('guest') . ', ' .
  						$db->quoteName('time') . ', ' . $db->quoteName('userid') . ', ' . $db->quoteName('username')
  					)
  					->values(
  						$db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . (int) $user->get('guest') . ', ' .
  						$db->quote((int) $session->get('session.timer.start')) . ', ' . (int) $user->get('id') . ', ' . $db->quote($user->get('username'))
  					);
  
  				$db->setQuery($query);
  			}
  
  			// If the insert failed, exit the application.
  			try
  			{
  				$db->execute();
  			}
  			catch (RuntimeException $e)
  			{
  				jexit($e->getMessage());
  			}
  		}
  	}
code: public function checkSession()
  	{
  		$db = JFactory::getDbo();
  		$session = JFactory::getSession();
  		$user = JFactory::getUser();
  
  		$query = $db->getQuery(true)
  			->select($db->quoteName('session_id'))
  			->from($db->quoteName('#__users_sessions'))
  			->where($db->quoteName('session_id') . ' = ' . $db->quote($session->getId()));
  
  		$db->setQuery($query, 0, 1);
  		$exists = $db->loadResult();
  
  		// If the session record doesn't exist initialise it.
  		if (!$exists)
  		{
  			$query->clear();
  
  			if ($session->isNew())
  			{
  				$query->insert($db->quoteName('#__users_sessions'))
  					->columns($db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('time'))
  					->values($db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . $db->quote((int) time()));
  				$db->setQuery($query);
  			}
  			else
  			{
  				$query->insert($db->quoteName('#__users_sessions'))
  					->columns(
  						$db->quoteName('session_id') . ', ' . $db->quoteName('client_id') . ', ' . $db->quoteName('guest') . ', ' .
  						$db->quoteName('time') . ', ' . $db->quoteName('userid') . ', ' . $db->quoteName('username')
  					)
  					->values(
  						$db->quote($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . (int) $user->get('guest') . ', ' .
  						$db->quote((int) $session->get('session.timer.start')) . ', ' . (int) $user->get('id') . ', ' . $db->quote($user->get('username'))
  					);
  
  				$db->setQuery($query);
  			}
  
  			// If the insert failed, exit the application.
  			try
  			{
  				$db->execute();
  			}
  			catch (RuntimeException $e)
  			{
  				jexit($e->getMessage());
  			}
  		}
  	}
code_tokens: public function checkSession ( ) { $ db = JFactory :: getDbo ( ) ; $ session = JFactory :: getSession ( ) ; $ user = JFactory :: getUser ( ) ; $ query = $ db -> getQuery ( true ) -> select ( $ db -> quoteName ( 'session_id' ) ) -> from ( $ db -> quoteName ( '#__users_sessions' ) ) -> where ( $ db -> quoteName ( 'session_id' ) . ' = ' . $ db -> quote ( $ session -> getId ( ) ) ) ; $ db -> setQuery ( $ query , 0 , 1 ) ; $ exists = $ db -> loadResult ( ) ; // If the session record doesn't exist initialise it. if ( ! $ exists ) { $ query -> clear ( ) ; if ( $ session -> isNew ( ) ) { $ query -> insert ( $ db -> quoteName ( '#__users_sessions' ) ) -> columns ( $ db -> quoteName ( 'session_id' ) . ', ' . $ db -> quoteName ( 'client_id' ) . ', ' . $ db -> quoteName ( 'time' ) ) -> values ( $ db -> quote ( $ session -> getId ( ) ) . ', ' . ( int ) $ this -> getClientId ( ) . ', ' . $ db -> quote ( ( int ) time ( ) ) ) ; $ db -> setQuery ( $ query ) ; } else { $ query -> insert ( $ db -> quoteName ( '#__users_sessions' ) ) -> columns ( $ db -> quoteName ( 'session_id' ) . ', ' . $ db -> quoteName ( 'client_id' ) . ', ' . $ db -> quoteName ( 'guest' ) . ', ' . $ db -> quoteName ( 'time' ) . ', ' . $ db -> quoteName ( 'userid' ) . ', ' . $ db -> quoteName ( 'username' ) ) -> values ( $ db -> quote ( $ session -> getId ( ) ) . ', ' . ( int ) $ this -> getClientId ( ) . ', ' . ( int ) $ user -> get ( 'guest' ) . ', ' . $ db -> quote ( ( int ) $ session -> get ( 'session.timer.start' ) ) . ', ' . ( int ) $ user -> get ( 'id' ) . ', ' . $ db -> quote ( $ user -> get ( 'username' ) ) ) ; $ db -> setQuery ( $ query ) ; } // If the insert failed, exit the application. try { $ db -> execute ( ) ; } catch ( RuntimeException $ e ) { jexit ( $ e -> getMessage ( ) ) ; } } }
docstring: Checks the user session.
  
  If the session record doesn't exist, initialise it.
  If session is new, create session variables
  
  @return  void
  
  @since   11.1
  @deprecated  4.0
docstring_tokens: Checks the user session .