3

I added several domain in one joomla website by using VirtualDomains extension. All the domain are in same Joomla site but pointing to different categories. I need to know how could it be possible to share the session between these domains ?? I mean when a user is do login inside DOMAIN1 will be remain logged in DOMAIN2,3 and goes on.

I know there is plugins such JSM, but I think there's very easy and better solution because it's not multisites but only multidomains in one joomla core. Would you please help me with your comments. Thanks in advance Just mention that I don't want to use 3rd party extensions but only codes inside joomla or its features.

  • may I know which JSM plugin are you talking about? can you provide a link to it, in your question description – Anant Oct 6 '16 at 11:34
3

I have figured out how to actually synchronize user login for all sub domains of joomla!. What Joomla does is it stores the session id of a user on a cookie that is: enter image description here Session cookie But the name of the cookie is a unique string and the value it has comes from the #__sessions table of your joomla, it is the session id of the user or guest, the name of the cookie changes for every Joomla installation. This means this name will be something else on your site. To get the name of the cookie you need to call the function getName() on the session object as

$sess=JFactory::getSession(); $sessName=$sess->getName();

Now you have the name of the cookie, you need to set the session id of the user that was logged in on the other domain you can get it using ip and apply different filters for it and store it along with the user id. If you get same value set the session id for that user to the cookie. Now setting the value has already logged in the user, but the changes won't reflect until you refresh, so try using

$app = JFactory::getApplication();
$app->redirect(JURI::current());

just after you set the value, also remember to delete ip and all info just as the user logs out or other user wont be able to log in.

This is how I get passed this issue, so thought it might help someone in future ,if you figure out a better way please share.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.