Home > Backend Development > PHP Tutorial > 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
Release: 2023-03-02 14:22:02
Original
1335 people have browsed it

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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.

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template