I would like to refresh my php page when the database is updated. I've already done it, but it refresh only one session so, if i have more than one user logged in, the others have to refresh the page manually. I would like to have an automatic refresh that refresh all browser session and not the single. Thanks
Asked
Active
Viewed 135 times
0
-
3This is not a trivial problem to solve. To know when the database has been updated you would be best using the observer pattern and have the server send a message to all connected users which forces their UI to refresh. Something like Websockets would be perfect for this. – Rory McCrossan Jan 27 '21 at 15:25
-
Thanks for your answer. There is not a method without WebSocket? I've preferred to use jQuery – z_Semmy Jan 27 '21 at 15:27
-
jQuery is a front-end JS framework for working with the DOM. Your problem is a multi-layered transport issue. You'll need to create an entire client and server side solution to make it work as you require. – Rory McCrossan Jan 27 '21 at 15:29
-
The alternative would be probably to send an AJAX request every x seconds to check if new data is available. Using this method would probably give your server a lot of requests, **which is not practical**, this could be viable if you knew you wouldnt have many users. I would recommend you to stick to what @RoryMcCrossan wrote. – Definitely not Rafal Jan 27 '21 at 15:32
-
Possibly related: https://stackoverflow.com/questions/35473356/is-there-any-javascript-tcp-soket-library-for-php-like-signalr-with-net – freedomn-m Jan 27 '21 at 15:32
-
Thanks all for your support – z_Semmy Jan 27 '21 at 16:36
1 Answers
0
You can use Mercure https://mercure.rocks + (maybe) Vulcain https://github.com/dunglas/vulcain

qdequippe
- 1,075
- 6
- 15