Ivan Gretsky Posted October 20, 2021 Share Posted October 20, 2021 Good day everyone! Hope you all safe and healthy! I am thinking about a rather ambitious project (for me). It should consist of a number of ProcessWire based sites which will serve the same group of registered users. I need to make the user registration a one time process. And I need to share the user data across the sites. Single sign-in is also in plans. I am thinking about placing the user info and all the user data in one installation and somehow sharing it between all the other. But I am open to any suggestions. Please share your thoughts and experience on the topic. I am only in the very beginning and trying to estimate is it even doable. Link to comment Share on other sites More sharing options...
Rudy Posted October 20, 2021 Share Posted October 20, 2021 My first thought is to use Redis for your session storage. I have a modified SessionRedis module that works on PW3.x with Predis if you want a copy. 2 Link to comment Share on other sites More sharing options...
horst Posted October 21, 2021 Share Posted October 21, 2021 10 hours ago, Rudy said: a modified SessionRedis module that works on PW3.x with Predis if you want a copy. I want to have a copy, if I can. ? ? Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted October 21, 2021 Author Share Posted October 21, 2021 @Rudy, surely I want a copy) But even more than that I want an explanation how to use it and how exactly will it fit my case. Could you please write a little more about it if you got time? Link to comment Share on other sites More sharing options...
Rudy Posted October 24, 2021 Share Posted October 24, 2021 Here is the customized module. You will need to run: composer require predis/predis to use it. Add the following settings to your `config.php` $config->redis_session_server_ip = '127.0.0.1'; $config->redis_session_server_port = 6379; $config->redis_session_server_db = 0; $config->redis_session_server_prefix = "PHPSESSID:"; $config->redis_session_server_ttl = 1800; Change the session prefix to whatever you want. Once installed, you can then share the same session (using the prefix) across multiple sites as long as those sites are reading/writing to the same redis server. SessionHandlerRedis.zip 2 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted October 25, 2021 Author Share Posted October 25, 2021 Cool stuff, @Rudy! May I ask a few additional questions? Do you limit the ability to login/register to only one installation? How? You do not re-create users on all installations, do you? Are you using user info from one installation in all the others? I mean something like $user->hasRole() and things like finding users? How? Are you using API call to other instances? Link to comment Share on other sites More sharing options...
Rudy Posted October 25, 2021 Share Posted October 25, 2021 @Ivan Gretsky my usage is slightly different than yours. It's more for running a website on a multiple servers through a load-balancer. I have my database running on AWS RDS and a separate Redis server. I think you should: - limit the login/register to only one installation - use either database or redis to store your sessions - use AppAPI module to make REST calls from the primary site 2 Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted October 25, 2021 Author Share Posted October 25, 2021 Thanks for the great suggestions! Will make my mind around it and try. If anyone has other ideas or experience on the topic, please share. I did not consider REST API for using $user data from the main registration site on the other installations (and do not have expertise in this). Are there other (simpler? more PW-ish?) ways to do it? 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