Hi I am trying to fetch data from joomla session table based on session id. I am using code as under and able to get session id but when i am trying to get username based on bellow mentioned query i am not getting any output. So please help/guide me if there is problem in query. I had also check column name(if i mistype) with data table and those are correct.
session_start();
$_session_id=session_id();
echo "your session id is ".$_session_id;
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// $query = "SELECT username". " FROM izj5n_session"." WHERE session_id = $_session_id";
/* $query->select('username');
$query->from('izj5n_session');
$query->where('session_id=$_session_id');*/
$query
->select('username')
->from('izj5n_session')
->where('session_id=$_session_id');
$db->setQuery($query);
$rows = $db->loadResult();
$itemrow = $rows;
print $itemrow;
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport('joomla.filesystem.file');
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
echo $user->username
just guessing...
$query = "
SELECT username
FROM Izj5n_session
WHERE session_id = $_session_id;
";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.