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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STILL CAN NOT WRITE COOKIES!!! 2

Status
Not open for further replies.

overyde

Programmer
Joined
May 27, 2003
Messages
226
Location
ZA
Hi,
I've read through a few forums and this problem seems quite common. I can not write any cookies. I've set up my setcookie right but it doesn't seem to be saving it. I have cookies enabled on my browser but to no avail. I'm running Windows XP, Apache 2.0.43, MySQL 4.0.4 and PHP 4.2.3.
Anyone, any ideas?
 
Here are two simple scripts:

test_set_cookies.php:
Code:
<?php

setcookie ('foo', 'bar');

setcookie ('bar', 'foo');

print '<html><body><a href=test_read_cookies.php>click here</a></body></html>';

?>


test_read_cookies.php:
Code:
<?php

print '<html><body><pre>';

print_r ($_COOKIE);

print '</pre></body></html>';

?>

Place these in the same directory, point your browser to one then click the link. What do you get?

Want the best answers? Ask the best questions: TANSTAAFL!
 
The first page says:
click here

When I click on it the second page displays:

Array
(
[foo] => bar
[bar] => foo
)

Does this make sense?
 
TO me Yes, the

the first one [foo] => bar
the foo means the name of the cookie
and bar is the value

the second one is the opposite

if you just want to see what's the value of foo then you should

echo $_COOKIE[&quot;foo&quot;];

see under your cookie folder u should see a cookie with the file name something like user@yourdomain
 
To you both...
Thank-you soooooooo much. I can start growing my hair again!!! Fantastic. Thanks ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top