[thelist] Some PHP & Image questions

Burhan Khalid burhankhalid at members.evolt.org
Fri Mar 8 10:53:00 CST 2002

[ snippity snip ]
Cookies are evil, more evil than client-side java dynamic menus. :-) <duck/>

>TBH, I think it'd be much easier to do this with GET variables:
>i.e., figure out the random number on the target page, and forget
>cookies altogether. Even better, drop the show=next / show=prev stuff
>altogether, and create the target ids as links on the original page:
>?id=2347 // prev
>?id=2349 // next
>?id=random // special case

You know, that's what I was going to do initially. I figured that since
this is all a learning experience, might as well use cookies.
Had I known it was going to be this bad, I would have dropped it altogether.

>But anyhow:
>>$cookie  = $HTTP_COOKIE_VARS["RandomVal"];
>>I wanted to store for that site. This time, I want to use cookies, and am
>>running around in circles (or so it seems).
>Lemme know where I'm going wrong with this:
>- get a var ($cookie) from a cookie ($RandomVal)
>- if it doesn't exist then set it to a random value
>- otherwise
>    - if they want 'next' then add 1 to $cookie (not THE cookie, just
>a copy of the cookie's var)
>    - if they want 'previous' subtract one from $cookie
>- If -- there's no cookie set then a new cookie is created, but the
>current page is kinda stuffed, because it can't find out what that
>value is. If this is the source of the problem, then set $cookie to
>the random number, and then set the real cookie $RandomVal to
>$cookie's value.
>- Otherwise -- there is a cookie, so work with $cookie and add or
>subtract. But this isn't going to affect the real cookie... clicking
>'next' 'next' 'next' is going to return the same page because the
>real cookie is not altered, only the local variable $cookie (am I
>sick yet of differentiating between the 'real' cookie, i.e.
>$RandomVal and the not-really-a-cookie-but-called-a-cookie $cookie?
>save yourself a debug nightmare and change those var names :-) ).

Yikes -- Now I've got an interesting jar of cookies. :(

>My vote, FWIW, is to drop cookies entirely and use GET vars instead.



Thanks a bunch

More information about the thelist mailing list