Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
472 views
in Q2A Core by
Appreciate the quick response. Here's what my code looks like now:

    function qa_get_logged_in_user($qa_db_connection)
    {
        session_start();

        if ($_COOKIE["SMFCookie10"]) {
            $result=mysql_fetch_assoc(
                mysql_query(
                    "SELECT ID_MEMBER, memberName, emailAddress, ID_GROUP FROM smf_members WHERE ID_MEMBER=".
                    "(SELECT ID_MEMBER FROM smf_log_online WHERE session='".mysql_real_escape_string($_COOKIE["SMFCookie10"], $qa_db_connection)."')",
                    $qa_db_connection
                )
            );
           
            if (is_array($result))
                return array(
                    'userid' => $result['ID_MEMBER'],
                    'publicusername' => $result['memberName'],
                    'email' => $result['emailAddress'],
                    'level' => $result['ID_GROUP'] ? QA_USER_LEVEL_ADMIN : QA_USER_LEVEL_BASIC
                );
        }
       
        return null;
    }

However, I get an error saying  "Undefined index: SMFCookie10"

I am checking with the SMF community on how to read the cookie that SMF sets. See:

http://www.simplemachines.org/community/index.php?topic=371972.0

Thanks.
related to an answer for: SSO with Simple Machines Forum (SMF)

1 Answer

0 votes
by
 
Best answer
Question2Answer uses strict PHP error checking, so put an @ sign before $_COOKIE["SMFCookie10"] in the first if().

Welcome to the Q&A site for Question2Answer.

If you have a question about Q2A, please ask here, in English.

To report a bug, please create a new issue on Github or ask a question here with the bug tag.

If you just want to try Q2A, please use the demo site.

Categories

...