It would be more efficient to forgo the cookies and use the query results in your anchor tags.
Is there some reason you don't use SESSION variables. Which are like COOKIES only better!
<!--- GET THE 4 RECORDS ---> <CFQUERY NAME="Session.GetCategories" DATASOURCE="#datasource#"> SELECT cat_uid,cat_title FROM categories WHERE cat_uid IN (#valuelist(Validateinstall.install_preferences)#) ORDER by cat_title </CFQUERY> <!--- DISPLAY THE 4 HYPERLINKS ---> <cfoutput query="session.GetCategories"> <a href="cat.cfm?catuid="#session.GetCategories.cat_uid#",#urlEncodedFormat(session.GetCategories.cat_title)#" class="reg_text">#session.GetCategories.cat_title#</a> </cfoutput>
that's interesting, I did not know you could read the results of a query directly into a session like that.
The issue I have is that we are running this on a shared server, and I know that this page could potentially receive a large amount of hits.
My concern I have is that there could be problems with too many sessions on the server at any time, I have no control over the administrator settings, plus the session could expire.
I figured that a cookie was a safer way to ensure that I did not have to be too concerned about the server settings.
Sessions do expire. If you are trying to persist this data for days and days, the first choice would be a database, or other data store, that would store the query recordset tied to a user specific key. You would then just store the key in a single cookie.
Working out for there, you can store the recordset itself in a cookie as long as it is not too large. You just have to incode it, <cfwddx....> would be the old school way to encode it, there are others now adays.
Or you can continue your current option. I would probably use a <cfloop from="1" to="4" index="i"> to consolidate that output code some.
yeah, I did wonder about stuffing that cookie with more data.
You think a CFLOOP over the results is quicker than just hard coding it to display each cookie?
I don't know about FASTER?
But I would think it would be easier to edit and maintain, which 9 times out of 11 is the more expensive and critical aspect.
True, normall I would use a loop but with it being a page that is going to get a lot of traffic I thought for this particular situation I'd avoid the loop, and try to squeeze as much as possible
sessions were a no go due to the risk of expiring. It looks like I've actually probably got the best solution in place for my situation.
I guess I'll leave it as-is.
Thanks for the input guys, I did learn something regarding the sessions into a query, very nice!