I've read all "cookie" threads..I write but can't

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
3dron
Forum Commoner
Posts: 40
Joined: Sat Feb 01, 2003 10:25 pm

I've read all "cookie" threads..I write but can't

Post by 3dron »

If I write the cookie like this:
setcookie ("test", "robots")

I can retrieve it fine with:
echo $HTTP_COOKIE_VARS["test"]

If I write a cookie with:
setcookie ("test", "robots", time() + 3600, "/", ".mydomain.com", 1)

I see the file show up in my cookies directory. But when I go to retrieve with:
echo $HTTP_COOKIE_VARS["test"]

I get nothing.

Am I missing something? I've looked everywhere.

RR
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

Try var_dump($HTTP_COOKIE_VARS);

Tell us what you see.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Have you done a:

Code: Select all

echo '<pre>';
print_r($HTTP_COOKIE_VARS);
echo '</pre>';
to check if any cookie can be retrieved.

Have you tried putting your full domain instead of '.mydomain.com' - just for testing.

Mac
3dron
Forum Commoner
Posts: 40
Joined: Sat Feb 01, 2003 10:25 pm

Post by 3dron »

I dumped and no it wasn't there? Only variables from the bulletin board I use came up.

I then tried adding the "www". No luck either.

I see in the cookie text file my variables are there along with the BB variables that do show up.

Why are my variables not showing up with the dump?

Help

RR
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Post by Sevengraff »

you turned on secure, are you using https?
3dron
Forum Commoner
Posts: 40
Joined: Sat Feb 01, 2003 10:25 pm

Post by 3dron »

no I haven't purposely turned on scure. No I'm not using https. Whay are the other variables in same text file reading fine?

RR
User avatar
Sevengraff
Forum Contributor
Posts: 232
Joined: Thu Apr 25, 2002 9:34 pm
Location: California USA
Contact:

Re: I've read all "cookie" threads..I write but ca

Post by Sevengraff »

3dron wrote:If I write a cookie with:
setcookie ("test", "robots", time() + 3600, "/", ".mydomain.com", 1)

I see the file show up in my cookies directory. But when I go to retrieve with:
echo $HTTP_COOKIE_VARS["test"]
the 1 at the end there means secure is on. should be

setcookie ("test", "robots", time() + 3600, "/", ".mydomain.com", 0)

if you don't want secure on.
3dron
Forum Commoner
Posts: 40
Joined: Sat Feb 01, 2003 10:25 pm

Post by 3dron »

Right on!!! Thanks!!!

RonR
Post Reply