#21569 [Bgs]: PHP can't set cookies after a test with an unset variable
| From: | msopacua@php.net | Date: | Mon, 13 Jan 2003 23:22:43 +0000 |
| Subject: | #21569 [Bgs]: PHP can't set cookies after a test with an unset variable | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-29929@lists.php.net to get a copy of this message | ||
ID: 21569
Updated by: msopacua@php.net
Reported By: ElfQrin@ElfQrin.com
Status: Bogus
Bug Type: Unknown/Other Function
Operating System: Windows 2000 only
PHP Version: 4.3.0
New Comment:
Does it work on those other machines, because you already have accepted
cookies, or because they run another OS?
Please make sure you understand how cookies work, specifically, that
they are only 'visible at the next page'.
Also make sure you don't have some automated blocking in effect for the
Windows 2000 machine, by verifying with plain telnet, if the
'SetCookie: ' header is sent rather than trusting the browser.
Previous Comments:
------------------------------------------------------------------------
[2003-01-13 16:47:53] ElfQrin@ElfQrin.com
Why does it affect only Windows 2000, while the very same PHP version
with the same php.ini file works fine on Windows 98 ? And it works
fine on Linux too?
To make it clearer, the "workarounds" are needed only if the scripts
run under Windows 2000, so that the example script returns "1" on
Windows 2000 and "3" on Windows 98 or Linux.
------------------------------------------------------------------------
[2003-01-13 16:37:48] sniper@php.net
There's really no bug here. You're getting a notice about unitialized
variable which causes the rest of the headers not to get send. Try
adding 'error_reporting(0);' in the beginning of your script..
------------------------------------------------------------------------
[2003-01-13 10:48:18] ElfQrin@ElfQrin.com
Workaround #2:
At the beginning og your script, "declare" any possibly unset variable
that will be invoked:
if (!isset($test)) {$test="";}
------------------------------------------------------------------------
[2003-01-13 10:07:12] ElfQrin@ElfQrin.com
Workaround (which doesn't mean this bug shouldn't be fixed):
To perform tests:
if (!isset($test) || $test=="") { echo ""; }
To set a variable:
$a=""; if (isset($test)) { $a=$test; }
------------------------------------------------------------------------
[2003-01-13 10:05:53] ElfQrin@ElfQrin.com
I've found out that the problem is not limited to tests. It happens
every time you invoke an unset variable before than setting a cookie.
In the previous example, try
$a = $test;
instead of
if ($test=="") { echo ""; }
and the setcookie won't work as well.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/21569
--
Edit this bug report at http://bugs.php.net/?id=21569&edit=1