php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23893 setcookie fails if $_GET value is empty
Submitted: 2003-05-30 05:05 UTC Modified: 2003-06-09 08:43 UTC
From: info at splendense dot nl Assigned:
Status: No Feedback Package: CGI/CLI related
PHP Version: 4.3.2 OS: sunOS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
24 + 32 = ?
Subscribe to this entry?

 
 [2003-05-30 05:05 UTC] info at splendense dot nl
I'm running php as CGI API and register globals and i'm trying the following script:

<?php

$something = $_GET["something"];

$value = "this is a value";
if (!setcookie ("TestCookie", $value)) {
	print ("cookie NOT set!");
} else {
	print ("cookie set!");
}

?>

with the following outputs:

1. www.server.com/script.php?something=
outputs: 'cookie set!'

2. www.server.com/script.php
outputs: 'cookie NOT set!'

3. www.server.com/script.php?somehting=value
outputs: 'cookie set!'

4. www.server.com/script.php?something_else=
outputs: 'cookie NOT set!'

so if I try to read a variable (can be GET/COOKIE/POST/...) and it is not explicitly specified, even if it's empty, cookies can't be set anymore.

I think it has to do with being a CGI API, because on another server where it's installed as apache API I don't have this problem.

can anyone verify this?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-03 02:38 UTC] shane@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


unable to repro on apache/cgi/win32 with 4.2.3, 4.3.2 or CVS.

Perhaps you should consider (warnings were breaking setting the cookie for me):

<?php

if (isset($_GET["something"]))
	$something = $_GET["something"];

$value = "this is a value";
if (!setcookie ("TestCookie", $value)) {
	print ("cookie NOT set!");
} else {
	print ("cookie set!");
}

?>

Otherwise, you need to provide more details on configuration of your system.


 [2003-06-09 08:43 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 19:01:29 2024 UTC