tags:

views:

34

answers:

3

Sorry for the title but as im pretty worthless at php/mysql i couldnt figure out a good title

I'm currently creating a community for the fun.

I need to be able to get the all of the authed user's info all throughout the site.

Whats the best way to do this? Right now I just have a query in index.php (i include all pages thru index.php) that querys the users table where the id = session[id]. I guess this will really slow down the site as every user keeps reloading pages.

What i wonder is, is there a smarter way?

+1  A: 

Get the information when a user first logs in, then keep the data you need in the $_SESSION array.

GSto
A: 

you can get all vars through the $_SESSION variable print_r($_SESSION); should return the content of the session

streetparade
except that the values aren't in $_SESSION, they need to put them there first.
GSto
yepp thats true in all cases
streetparade
A: 

It doesn't sound like you should worry much about speed at the moment, querying the database on each request will be fine for now.

Once you get further into your project and maybe all your database queries are starting to slow down your site, THEN you should take a look at optimizations, like reducing the load on the database and caching details.

ozone
This isn't a micro-optimization he's talking about, this is a fundamental change to the architecture. running the same query over and over like they are talking about is completely pointless, and should definitely be changed right now.
GSto