I am trying to make a online chatting application.

How do I make a variable persist across users logged in from machines from different places in PHP?

I tried using session_write_close method but didn't work out.

Please guide with a step by step procedure. Many thanks.

有帮助吗?

解决方案

Sessions are per-browser. The session id is most commonly stored in browser cookies, or it can be passed around directly with each request. Either way, you cannot use the same session on different computers, not even multiple browsers on the same computer.

Instead of persisting the session, you can persist variables the same way you store user configurations, for example by saving settings in a database. The variables you want to store should be tied to the user account, not to the session.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top