Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing session between two different web browser

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 Firefox, but User B cannot login using IE on the same PC

Of what i googled session sharing between browsers can not be done if asked from server side

like image 956
Thanapon P. Avatar asked Dec 08 '25 09:12

Thanapon P.


2 Answers

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.

like image 127
Ben Avatar answered Dec 09 '25 22:12

Ben


You can make the login script such that as to it checks on login whether the user is already looged in or not. If logged in then it will reject any more further logins.

As said above PHP can store session ids in databases. Check the database for existance and then allow or disallow based on that.

like image 23
Debarko Avatar answered Dec 10 '25 00:12

Debarko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!