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
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.