|
Posted by Blayde on 11/05/06 19:53
On Nov 5, 10:59 am, "4site" <ian4s...@hotmail.com> wrote:
> 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...
Hey 4site,
Sounds like everything should work fine, but the browsers might be
caching cookie_test.php without the information on it. Have you tried
completely refreshing the page after cookie_test.php loads empty? You
might also check out the manual for header() as there is a good example
for stopping browsers from caching pages.
Good luck, Blayde
Navigation:
[Reply to this message]
|