[thelist] PHP help required please

Andrew Forsberg andrew at thepander.co.nz
Sun Feb 3 15:46:00 CST 2002


>setcookie("LOGININFO", "$username");
>
>thats the code that sets the cookie when it is told to set it in an if
>statement.
>I then want to be able to use the value of $LOGININFO like so:
>
>$sql = "INSERT INTO  '$LOGININFO' (prod_id,prod_name,prod_price) VALUES
>('1','2','3')";

Can you try putting phpinfo(); at the bottom of the page where the
cookie is apparently not working, and search through the cookie vars
it exposes to see where your username has gone. The fact that the
variable only appears to work on the page where the cookie is set
(ie, it's not read from the cookie yet, only from the $username
variable, which is why reading from $HTTP_COOKIE_VARS["blahblah"] is
a Good Idea (TM)), indicates that the cookie hasn't actually been set
at all (perhaps a problem with the if statement) -- or, that it's
doing something different entirely.

If you'd prefer not to search through the entire phpinfo() output for
your variables you could try: print_r ($HTTP_COOKIE_VARS); it'll look
funny in html, but you should be able to read it fine via your
browser's 'view source'.

Also, have you checked in your testing browser that a cookie has been set?


Cheers
Andrew

--
Andrew Forsberg
---
uberNET - http://uber.net.nz/
the pander - http://thepander.co.nz/



More information about the thelist mailing list