开发者

Could we use session to create a global variable for all client?

开发者 https://www.devze.com 2023-01-17 12:01 出处:网络
I saw this example in php manual page http://www.php.net/manual/en/session.e开发者_运维知识库xamples.php

I saw this example in php manual page http://www.php.net/manual/en/session.e开发者_运维知识库xamples.php The example will create a global session for all client. Can I use this example to create some global application for all client, instead of save it to DB or local file. What're the pros and cons of this method? Thanks for any help.


It might work, but I wouldn't recommend it... to much scope for potential confusion by othe rdevelopers working with the code, potential issues if you update session variables within the wrong scope, and the use of the term "session" for something that is not session-related can lead to a whole world of confusion


Yes it is possible by sharing the session id between two clients but sessions are only used to store temporary data of a user. So once a session is destroyed there is no way to retrieve that data.


No, this is not possible, or advised. A session is bound to one client, and clients do not share a session.

0

精彩评论

暂无评论...
验证码 换一张
取 消