API16

JTableSession/exists: Difference between revisions

From Joomla! Documentation

m clean up
m preparing for archive only
 
Line 4: Line 4:




{{subst:Description:JTableSession/exists}}
 


===Syntax===
===Syntax===
Line 46: Line 46:




{{subst:SeeAlso:JTableSession/exists}}
 


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=exists
  category=exists
  category=JTableSession
  category=JTableSession
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*
  format= ,,,
  format= ,,,
</dpl>
</dpl>

Latest revision as of 02:12, 25 March 2017

Description

Find out if a user has a one or more active sessions



Syntax

exists($userid)
Parameter Name Default Value Description
$userid $userid The identifier of the user

Returns

boolean True if a session for this user exists

Defined in

libraries/joomla/database/table/session.php

Importing

jimport( 'joomla.database.table.session' );

Source Body

function exists($userid)
{
        $query = 'SELECT COUNT(userid) FROM #__session'
                . ' WHERE userid = '. $this->_db->Quote($userid);
        $this->_db->setQuery($query);

        if (!$result = $this->_db->loadResult()) {
                $this->setError($this->_db->stderr());
                return false;
        }

        return (boolean) $result;
}



Examples

Code Examples