Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
in Q2A Core by
edited by
Next to my main site I plan to create another forum with another purpose (thus on another domain!).

I want the users from my main site to log-in into the new forum site - with their existing logins.

I found https://github.com/q2a/question2answer/blob/dev/qa-external-example/qa-external-users.php which seems quite complicated at first glance.


1. Is there any easy way to just tell q2a to use the other database's qa_users table instead?

2. Has somebody done something like this already? If so, what would be the code of qa-external-users.php?

3. What else to consider?

Thanks for sharing your experiences and ideas.

Q2A version: 1.7.4
Are both sites on the same server? Do they share the same database (with different prefix) or are they separate databases?

1 Answer

+2 votes
selected by
Best answer
Thanks, I missed that one!

So the solution is to use the same database, having each q2a installation with different prefixes (why I didn't think of this!). And having the same prefix for the users table, i. e. "qa_users".

Great to hear that the session sharing for the login works with your subdomains! In my case I have two different domains, so this will not work, to my knowledge. However, I think it's okay to ask my users to login at site B again :)
It should work for different domains also, provided they are on same server and accessing same mysql db.
It would be nice but I guess, they need to have the same session folder. Basically "You cannot set cookies for another domain." - https://stackoverflow.com/q/6761415/1066234 I need more testing to find out what define('QA_COOKIE_DOMAIN', '.myq2asite.com'); can do. Maybe there is some workaround...
I checked for subdomains but not for diff sites. Let us know the problems you see for diff domains.