Home  >  Article  >  Backend Development  >  Are there any problems with using session to save some global data?

Are there any problems with using session to save some global data?

WBOY
WBOYOriginal
2016-12-01 01:27:581299browse

As the title states, these data are shared data (such as site information, etc.). A friend asked me before if I wanted to pass variables across controllers in YII. I told him about configuration files and using redis and memcache, but he couldn't say it well. Finally, I said throw it to the session, and was despised. . What do you think?

<code>ps:一个刚出道的php请教。</code>

Reply content:

As the title states, these data are shared data (such as site information, etc.). A friend asked me before if I wanted to pass variables across controllers in YII. I told him about configuration files and using redis and memcache, but he couldn't say it well. Finally, I said throw it to the session, and was despised. . What do you think?

<code>ps:一个刚出道的php请教。</code>

If the information is shared by all users, it can be placed in the cache, but it must also have persistent storage. For unchanged data, it can be placed in the configuration file;
If it is the data of a single user session, then there is no problem in putting it in the session. I I wonder what clever tricks your friend has up his sleeve

It’s okay to save some global data, as long as it’s not too big. If it is only temporarily stored, then delete it after use.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn