I have some secure user information which is inserted as at the top of my template (I am using CMS Made Simple, pages are built from various component parts, so code is split between locations).
I want to access the array of user attributes at multiple points in the site, the solution that sprung to mind was to, at point of arrival, store the attributes in MySQL and then call on them directly from that where ever I am in the site.
My simple question: is this a good way to do things? Or is there an accepted way to get arrays globally accessible (I hear that actually using the global array is frowned on these days?)
If the variables you are accessing are user specific, this is exactly the sort of thing that the
$_SESSIONvariable was created for. Don’t forget to make call tosession_start()at the beginning of each script that accesses it, or none of your previously set values will be there (and any values you set will not be saved).