Best practices for storing global data in PHP?

I am running a web application that allows the user to log in. The user can add / remove content to his "library", which is displayed on a page with the name "library.php". Instead of querying the database for the contents of the user library each time they load "library.php", I want to store it globally for PHP when the user logs in, so the query is only launched once. Is there any best practice for this? FX saving their library in an array in a session?

thank you for your time

+5
source share
7 answers

$_SESSION , ( ), , , , .

, - , , " , library.php".

+7

. .

, . , ; .

, , , ( Remi), . , .

+2
+1

PHP script , , -, .

, , . , , , - , , .

php , DB, php .

+1

db, memcached, :

memcached [..] - .

+1

, . , , :

$_SESSION['key'] = "value";

, , .

0
source

you care about performance; Note:

  • A session can use a database or file to store data. Database
  • used here instead of files, for it performance and features.

use the database , it is intended for use in such situations!

0
source

All Articles