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! 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? 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. 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? 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. 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. 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. Link to comment https://forums.phpfreaks.com/topic/245727-creating-a-globals-file/#findComment-1262123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.