Caching variables in the $_SESSION variable?

后端 未结 3 1738
暗喜
暗喜 2021-02-14 16:09

I\'m making a php web application which stores user specific information that is not shared with other users.

Would it be a good idea to store some of this information i

3条回答
  •  逝去的感伤
    2021-02-14 16:19

    That could work well for relatively small amounts of data but you'll have to take some things into consideration:

    1. $_SESSION is stored somewhere between requests, file on disk or database or something else depending on what you choose to use (default to file)
    2. $_SESSION is local to a single user on a single machine.
    3. sessions have a TTL (time to live), they dissapear after a set amount of time (which you control)
    4. Under certain circumstances, sessions can block (rarely an issue, but i've run into it streaming flash) If the data you mean to cache is to be accessed by multiple users you're quickly better off caching it seperately.

提交回复
热议问题