PWS, WIN98, PHP4.0.3pl, Cookies
| From: | Jeremy Pagee | Date: | Fri, 03 Nov 2000 23:08:07 +0000 |
| Subject: | PWS, WIN98, PHP4.0.3pl, Cookies | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-23634@lists.php.net to get a copy of this message | ||
Has anyone had any problems in getting cookies to set in the following system?- WIN98, PHP4.0.3.pl,
PWS
When I try to set a cookie, and then refresh the page or go to another page, I cannot access that
value at all, either through the global syntax ($CookieName) or the
$HTTP_COOKIE_VARS["CookieName"] Array. This version of the php.ini file tells me that
track_vars is always on, and I set register_globals to "on". My variables_order is
"EGPCS" which is as it should be, although I've tried different combinations to see
if it would have any effect but it didn't. To debug my script, I got rid of any conditional
checks before setting my cookie, so the script starts right off by setting the cookie as in:
<?
setcookie("CookieName","Hello");
// I've also tried filling all of the optional parameters but this made no difference
?>
I use another script in another page to test it:
<?
print($HTTP_COOKIE_VARS["TestCookie"]);
// Also tried print($TestCookie);
var_dump($GLOBALS);
?>
So, I run the first script, then browse to the second one. It gives me an error that index
"TestCookie" index is invalid, which is confirmed by the fact that after the var_dump, the
HTTP_COOKIE_VARS array is empty. Using print($TestCookie); just gave me an error that it is an
undefined variable.
Note - My Post and Get vars can always be accessed without a problem, either globally or through
HTTP_*_VARS.
I was using php4.0.1 before and I had the same problem (I was also using php.ini-dist for the
php.ini file to ensure that I would have access to gloabl variables etc, no luck)
There are no spaces preceding the opening "<?" and the script is exactly as above, i.e.
I don't think any output is being sent to the browser before I call setcookie (I'm
reasonably sure of that, since I don't get the error message of attempting to change headers
after they've already been sent; [I even tried changing output_buffering to "on", but
that made no difference] ). I've tried using session variables, but I believe they are cookie
dependant (?) so they don't work either. So, the setcookie function does not return an error to
me yet there are no cookies stored after I've run it and refreshed or gone to another page.
Does anyone have any ideas or suggestions about this? THe exact same script works fine on a Linux
box using Red Hat and Apache. It is not a browser dependant problem, as I've tried it in both
Explorer 5.0 and Navigator 4.7. I can circumvent the need for cookies by storing the value in a
database or passing it via get or post, but I would just like to know why cookies aren't
working for me.
Cheers,
Jeremy