androbey Posted May 19, 2021 Share Posted May 19, 2021 Hi all, I have a special setup right now, which uses two ProcessWire instances with two different databases (no "multi-site" setup), let's call them site1 and site2. I want to access data from site1 on site2 through the multi-instance feature. It happens that some users of site2 may have an account on site1 as well and for them I store their user id on site2. Now I want to force login those users, when I want to use a page find function. This way I can still manage access to pages on site1. If I don't login those users on site1, no results are returned for access controlled pages, unless I add the check_access flag to 0 (which I want to avoid). So far so good. However, once I force login those users on site1 the user is logged out of site2 automatically (which means the user acctually cannot use the site). Both sites are running exact same versions (v 3.0.178) and have different sessions names. // on site2 $path = '/home/modules/www/site1'; // The root URL for the PW installation $url = 'http://examplesite1.com'; // Create a new ProcessWire instance $site1 = new ProcessWire($path, $url); //get user object from site1 -> "$userSite1" //force login user.. $site1->session->forceLogin($userSite1); $myPages = $site1->pages->find("template=my_access_controlled_template"); // pages are returned that $userSite1 has access to //at this stage currently logged-in $user of site2 is logged out I hope the problem is clear. Is there anything I can do to avoid the log out (without having to use check_access flag)? Link to comment Share on other sites More sharing options...
androbey Posted June 4, 2021 Author Share Posted June 4, 2021 I still don't get why I am logged out of site2 when "force login" on site1, but replacing $site1->session->forceLogin($userSite1); //with following (replacement): $site1->session->setCurrentUser($userSite1); seems to have the desired effect without logging out the user on site2. Link to comment Share on other sites More sharing options...
wbmnfktr Posted June 4, 2021 Share Posted June 4, 2021 Similar topic therefore a recommendation: Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now