pengu Posted August 26, 2011 Share Posted August 26, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/245727-creating-a-globals-file/ Share on other sites More sharing options...
MasterACE14 Posted August 26, 2011 Share Posted August 26, 2011 you could just do this upon user login and store it in the session? Quote Link to comment https://forums.phpfreaks.com/topic/245727-creating-a-globals-file/#findComment-1262107 Share on other sites More sharing options...
pengu Posted August 26, 2011 Author Share Posted August 26, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245727-creating-a-globals-file/#findComment-1262109 Share on other sites More sharing options...
MasterACE14 Posted August 26, 2011 Share Posted August 26, 2011 I'm not familiar with how the vBulletin globals.php works/looks. Could you post the code so I can get a better understanding of what you're trying to achieve? Quote Link to comment https://forums.phpfreaks.com/topic/245727-creating-a-globals-file/#findComment-1262111 Share on other sites More sharing options...
pengu Posted August 26, 2011 Author Share Posted August 26, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245727-creating-a-globals-file/#findComment-1262115 Share on other sites More sharing options...
MasterACE14 Posted August 26, 2011 Share Posted August 26, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245727-creating-a-globals-file/#findComment-1262121 Share on other sites More sharing options...
pengu Posted August 26, 2011 Author Share Posted August 26, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245727-creating-a-globals-file/#findComment-1262123 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.