Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookies - better solution? 1

Status
Not open for further replies.

Microbe

Programmer
Oct 16, 2000
607
AU
Hello,

Further to my post yesterday about cookies being retrieved in a different order using client side JS compared to Vbscript.

This is becoming a nightmare and I wonder if anyone has an idea.

The person doesn't want to use a database, despite all the obvious advantages...sigh...extra cost for hosting is a problem it seems.

When a customer places an order via the cart I have written I want to be able to give them to opportunity of just submitting the same order when they return.

To elaborate, the product is contact lenses - when someone places an order they have to provide a bunch of information based on the prescription. There are 22 values per pair of lenses that need to be saved and recalled plus their contact and optometrist details (another 23 values)

Setting a cookie is no problem, the problem is that the order of key/value pairs ends up in a mess compared to when it is written. There is no way I can assume that the 10th value written is the 10th value retrieved, they are all jumbled up.

Parsing it using string comparisons will work, especially easy if only one order, but if they order say 5 pairs of lenses and I have over 100 values to save and then recall, it becomes a real issue, prone to error.

I know, I know, if it was a db it would be a cinch, but it isn't.

Does anyone have any thoughts on this that might steer me towards a solution?

Steve Davis
hey.you@hahaha.com.au
 
Why not just name each Cookie key/subkey meaningfully, so you can refer to them by name, rather than (assumedly) ordinal? codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
<insert witticism here>
 
Here's a little test I made just then:

<%@enablesessionstate=&quot;false&quot; language=&quot;vbscript&quot;%>
<html>
<head></head>
<body>
<%
dim lng_Count
if Request.Cookies(&quot;CartItem1&quot;)(&quot;ItemID&quot;) = &quot;&quot; then
'simulate a 'cart of items
randomize
for lng_Count = 1 to 10
Response.Cookies(&quot;CartItem&quot; & lng_Count)(&quot;ItemID&quot;) = &quot;GLS&quot; & (330 + lng_Count)
Response.Cookies(&quot;CartItem&quot; & lng_Count)(&quot;ItemName&quot;) = &quot;VisionCo Glasses &quot; & lng_Count
Response.Cookies(&quot;CartItem&quot; & lng_Count)(&quot;ItemCost&quot;) = round(rnd*10+1,2)
Response.Cookies(&quot;CartItem&quot; & lng_Count)(&quot;ItemQuantity&quot;) = int(rnd*3)
'etc
next
else
lng_Count = 1
while Request.Cookies(&quot;CartItem&quot; & lng_Count)(&quot;ItemID&quot;) <> &quot;&quot;
Response.Write Request.Cookies(&quot;CartItem&quot; & lng_Count)(&quot;ItemID&quot;)%><br>
<%=Request.Cookies(&quot;CartItem&quot; & lng_Count)(&quot;ItemName&quot;)%><br>
<%=Request.Cookies(&quot;CartItem&quot; & lng_Count)(&quot;ItemCost&quot;)%><br>
<%=Request.Cookies(&quot;CartItem&quot; & lng_Count)(&quot;ItemQuantity&quot;)%><br>
<% lng_Count = lng_Count + 1
wend
Response.Cookies(&quot;CartItem1&quot;) = &quot;&quot;
end if
%> </body>
</html>
codestorm
Fire bad. Tree pretty. - Buffy
select * from population where talent > 'average'
You're not a complete programmer unless you know how to guess.
<insert witticism here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top