Sharing session between two different web browser

前端 未结 3 969
無奈伤痛
無奈伤痛 2020-12-21 06:39

I want to make a PHP web application in which on a single PC there can only be one authentication session at a time i.e. User A login using

3条回答
  •  礼貌的吻别
    2020-12-21 07:37

    Theoretically, you could do this using session_id() and a database entry, although security will be tricky since a malicious user could try generating random session IDs to mimic a logged-on user's session.

    Session information is stored in a cookie in the client's browser, with a specified ID. By storing that ID and a JSON string of the data, whenever it's updated, various users could conceivably share the same data. They'd all have to poll the server once in a while to see if the data has been changed.

    But at that point, you don't need to use $_SESSION anymore, so it's pretty much defeated the purpose of your question. You can get the same behavior with regular variables, which would already be a security improvement.


    Short answer: No, that's not the point of sessions.

提交回复
热议问题