[thelist] Why cookies does not sets

Andrew Forsberg andrew at thepander.co.nz
Wed Feb 13 20:01:01 CST 2002


>hello people
>I'm using PHP4 (for win) and Apache 1.3 (for win) with IE 5 browser.
>I'm using setcookie() php function to set cookie variables, but it
>is not work correctly. When I user $HTTP_COOKIE_VARS[] to get
>variable, but  I still get nothing, even if I use security set (on
>Internet Option) to low.
>Why?

Hi

Can you show us the bit of code you're using to set the cookie, and a
snippet from where you're trying to read it?

Save something like this as testing_cookies.php on your server:

<?php
$test_var = "howdy doody";
setcookie("test_var", $test_var);
print ("<html><pre>");
print_r ($HTTP_COOKIE_VARS);
print ("</pre></html>");
?>

The first time you load the page it will print:

Array
(
)

On refreshing the page you should see:

Array
(
     [test_var] => howdy doody
)

This is because a cookie isn't accessible from the browser at the
time it is set. Have a look over the php cookie docs at:

http://www.php.net/manual/en/features.cookies.php

HTH
Andrew

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



More information about the thelist mailing list