How to display an alert from the server on different pages for different users separately?

Hi all, faced with the problem of how to implement the principle of different alerts:
  1. There are 6 users of them:
    • 3 user logged in
    • 3 the user is not logged in

  2. There are 3 pages:
    • 1st page "Articles" (this page shows all articles and the number of comments to each article)
    • 2nd page "One particular article" (on this page displays the contents of a specific article, block comments, and personal review )
    • 3rd page "Home" (home page)

  3. Location of users:
    • 1st authorised user is on 2nd page("One definite article")
    • 1st not an authorized user is on 2nd page("One definite article")
    • 2nd authorized user is on the 1st page("Articles")
    • 2nd not an authorized user is on the 1st page("Articles")
    • 3rd authorized user is on the 3rd page("Home")
    • 3rd non-authenticated user is on the 3rd page("Home")

  4. After adding a comment to the database, you need to:
    • That would be the 1st authorized user located on the 2nd page("One definite article"), I saw the comment in the block below the article
    • What would the 1st not an authorized user located on the 2nd page("One definite article"), I saw the comment in the block below the article
    • What would a 2nd authorized user located on the 1st page("Articles"), saw a +1 comment to the article to which a comment has been added
    • What would the 2nd not being an authorized user on the 1st page("Articles"), saw a +1 comment to the article to which a comment has been added
    • That would be the 3rd authorized user is on the 3rd page("Home"), received a Push notification(like in VC, when a new message when you are on any page except the "Messages" you receive the Push notification on the bottom left of the page )
    • What would a 3rd not an authorized user is on the 3rd page("Home"), neither of which has received


Use Websocket, a server-side workerman.
After clicking to add a comment, first, using ajax, add data in the database, and what to do next I do not know...
March 19th 20 at 08:51
1 answer
March 19th 20 at 08:53
Too much text. Write in short. The right question is half the answer.

how to workerman-e, to the contents of $_COOKIE ?

I've already threw a link to my examples:
https://github.com/Reymundo_Schimmel89/workerman-examples
here is just an example with $_COOKIE:
https://github.com/Reymundo_Schimmel89/workerman-examples/bl...

visit articles no $_GET parameter that would indivicual user

so he should not be on the page of articles. $_GET is invoked in the websocket server.

On the page the articles should be as follows:
the <script>
 ws = new WebSocket("ws://127.0.0.1:8000/?user=<?=$user?>");
 ws.onmessage = function(evt) {alert(evt.data);};
</script>


Then this will propozitsia in the websocket server and will be available in $_GET

According to my example you can traverse in a get parameter any info, such as what this page or any ID of the article. And then using that info to fill in vabakutseline the array you want (eg so), who is where and later from the primary site to send the notification in websocket server based on hranica information (who is where on the website) sends a notification to whom it is necessary.

If it's too difficult, then maybe you should take something else instead of workerman, where there is already implementation of the scheme pub/sub. Although it may already in workerman is.

In my examples, I take off for the second time just shows how to send a message to a specific user, not all. Write new examples for your specific task I don't plan, I now have no time for it.

Important:
Cookies on port 80 and on port 1234 different, this you can verify by opening the history query in the browser console.
To the cookie in the websocket server was the same as on the main website and the websocket server have to proxy, for example via nginx.
Something like:
location / php
location /websocket proxy_pass on 1234

Find more questions by tags WebSocketjQueryPHP