about globals, sessions & cookies.
I have a little question here.
I’m building my own component and it will have some filters possibles, eg. to filters the content by “days old” (days_active).
When running a query to show the items, the script would check :
-if the user set a days_active filter
–if not, if the admin set a days_active filter.
My question is:
How must I call the datas ?
I have set all the admin filters in
So to get the admin filter, I would get $bp->mycomponent->options[‘days_active’].
It’s in the global so here it’s rather ok.
Now for the user…
But if I run this each time, it will slow my component…
So where to store it ?
Is it a good idea to store that in sessions ? It could work both for logged in and non logged in users…
OR maybe in sessions for visitors and elsewhere for members ?
Thanks to give me some advices !
get_usermeta() will cache multiple calls on the same page, so you should be fine.
grosbouff, so you have a set of administrative default filter settings, and you’re going to let users set their own filters and customize existing queries? Is that right?
If so, then Andy is of course correct. It won’t need this in a session because once the plugin is loaded via buddypress, the info is available without any additional queries to the db once the data is acquired for the first time. It shouldn’t slow anything down, other than the initial gathering of the data.
Yes this is it.
So I don’t need to store that in sessions ? I don’t need to do anything, except get_usermeta when I need to ?
“the info is available without any additional queries to the db once the data is acquired for the first time”
…only on the page shown or for all plugin pages ?
- The topic ‘about globals, sessions & cookies.’ is closed to new replies.