Search code examples
sqljoomla

How to get session ID in sql in joomla


I'm working with vcharts in Joomla and trying tom implement charts based on who is logged in. Sadly vcharts only allows me to use SQL for queries and not PHP so How will I get the session ID then.


Solution

  • Based on the SO question Variables added to vchart joomla sql query not picked up (that exposes a relevant portion of the vcharts manual which joomla users must ordinarily pay to see...) it seems the placeholder that you can use in your SQL is:

    {loggedinuserid}
    

    So, you might write something like

    SELECT * FROM #__users WHERE id = {loggedinuserid}
    

    Of course this is just a guess because I've never used vcharts, nor have I seen the actual docs.

    If it doesn't like the #__ prefix placeholder, then I guess you'll need to manually replace it like this:

    SELECT * FROM lmnop_users WHERE id = {loggedinuserid}
    

    All this said, I have had some experience with the Plotalot extension and it's pretty good with great documentation.