|
Posted by 4site on 11/05/06 17:59
Hi all, this is probably stupidly easy but I'm struggling.
I am trying to understand why cookies only appear to be readable when a
web page is retrieved by *typing the url into the browser's address
box* but NOT when the same page is accessed *via a link from another
page*. I probably don't fully understand the mechanics of an HTTP
request...
Example:
The first page sets a persistent cookie:
<?php
$value = 'something';
setcookie("TestCookie", $value, time()+(24*365*3600));
?>
and contains a link - <a href="cookie_test.php?">Link to cookie
test</a>
The second page [cookie_test.php] contains the following code:
<?php
print "COOKIE DATA: <br />";
foreach ( $_COOKIE as $cookie_name => $cookie_value ) {
print "$cookie_name = $cookie_value <br />";
}
?>
When a) viewing cookie_test.php, using either Firefox 2.0 or IE7, via
the link from page one, the cookie data does not print out. But b) by
entering cookie_test.php into the address box and pressing return, this
causes the browser to display the cookie contents.
PHP Version 4.3.10
Could I have an explanation please and how do I retrieve cookie data in
case (a) ?
Thanks for your help...
[Back to original message]
|