Jump to content

Creating a "GLOBALS" file


pengu

Recommended Posts

Hi guys,

 

I'm just curious as to how I would go about to create a "globals.php" page much similar to the one vBulletin uses just as an example.

I have some ideas but I'm not 100% sure.

In my mind it works sort of like this.

 

- Do a query to grab all relevant data for the user

- Put it in an array

- Take data from array .. $array['user'] (example)

 

Could anyone tell me if I'm waaaaaaaaay off and if so offer some guidance, links perhaps?

 

Thank you! :)

Link to comment
https://forums.phpfreaks.com/topic/245727-creating-a-globals-file/
Share on other sites

you could just do this upon user login and store it in the session?

 

I could, but then I'd have a million things in sessions.

I also want something dynamic, so if the database changes, say more items are added, the sessions wont reflect this change.. unless set again.

I can't post too much.. sorry.

Basically vBulletin is able to do something as following.

 

somepage.php

<?PHP

   include "globals.php"; //can't remember what it is exactly called..

echo $vbulletin->userinfo["userid"];
echo $vbulletin->userinfo["posts"];

//etc etc

?>

 

Now I have my own database, seperate to vBulletin, full of information that I need.. lets say its a shopping cart as an example, basically wont something the same as this vbulletin to have like, I don't know a count of how many items are in "my" shopping cart.

 

I hope this helps.

In this case you either do what I mentioned above, or query your database for the data on a 'as needed' basis. This is common practice. Simply storing a heap of information in some kind of global configuration is not a good idea for security and performance reasons.

In this case you either do what I mentioned above, or query your database for the data on a 'as needed' basis. This is common practice. Simply storing a heap of information in some kind of global configuration is not a good idea for security and performance reasons.

 

Thanks for your help.. but I disagree about security.

Performance I'm not quite sure.

 

Will wait to see what others say.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.