[thelist] JS Cookie problem - more info!

Tom Dell'Aringa pixelmech at yahoo.com
Fri Jan 10 14:41:01 CST 2003


--- Morgan Kelsey <morgan at morgankelsey.com> wrote:
> > Ok, figured something out! Again, what I am doing is looking for
> a
> > few cookies within my cookie string. These cookies start with
> "pid"
> > and have a number after them, like:
> >
> > pid121=5
> > pid7=4
> >
> > Because I don't know how many might be in a cookie, or what the
> > values are, I figured I would run through a loop to the highest
> > number pid could be, and check for each one.
> >
> > So - my code to do that was this:
>
> ok, before .jeff tells you how ;p which will involove some yucky
> looping i
> predict....maybe you want to reconsider your approach here.
>
> it looks to me like you're trying to store complex data as simple
> data. pid123
> refers to product ID 123, i assume? and then the value is probably
> the qty for
> each? am i right?
>
> what happens if you need to store the price too, or the name? don't
> tell me you're
> going to go hit the DB up every time for those....

Ok, obviously more info is needed: I'm working on a project where PHP
pages, JavaScript data and a proprietary store app (Kurant Store
Sense) have to all play nice.

I'm only trying to track the number of items bought in a registry.
All I want to is, when a person adds an item to the cart, I want
remember how many. If he actually fulfils the order, then on the
confirmation page I want to get that info into my php script and make
the change in my DB.

NOW - the confirmation page is NOT a php page. I can't mess with
their database for this - the cart is in THEIR db and I have no
access there. I do have a mySQL db for my registry. It only keeps
track of what people put in there, and how many they want/have.

So really the only thing I can do is put that info in a cookie, and
pull it out at the end. I trigger my final php script AFTER the page
loads by putting this tag at the BOTTOM of the page:

<img src="track.php">

What i figure is I will then (somehow) take all these PIDs and pass
them along to my track.php page - whether I attach it as a
querystring, or dynamically build a form and submit it, not sure.
This is basically my last attempt at this, so if it doesn't work,
they don't get the functionality.

> what you need here is an array or some other complex datatype that
> will hold the<snip>

Yeah, as per above I can't do that.

Tom

=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the thelist mailing list