underthefake Posted December 12, 2010 Share Posted December 12, 2010 I want to include a variable (for example an object $user) in each PHP page. Previously I declared $var in an include file then included that file in every page, however it generates an error in Zend Studio and it's also not very good programming style. I want to know how I can do it any other way. I was thinking of using constants but I don't know if constants should be used for this purpose and also I do not think constants can be defined as objects. Thank you very much for your help. Quote Link to comment Share on other sites More sharing options...
litebearer Posted December 12, 2010 Share Posted December 12, 2010 using sessions and session variables you can 'carry' variable(s) to multiple pages http://www.tizag.com/phpT/phpsessions.php Quote Link to comment Share on other sites More sharing options...
underthefake Posted December 12, 2010 Author Share Posted December 12, 2010 using sessions and session variables you can 'carry' variable(s) to multiple pages http://www.tizag.com/phpT/phpsessions.php I have read online that large objects in the session will impact performance greatly. My objects will be quite large so I don't think using sessions will be the best. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted December 12, 2010 Share Posted December 12, 2010 if you don't want to store objects in sessions, store them in a database table and store the row identifier in a session var. Quote Link to comment 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.