php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41982 cookie fails to set
Submitted: 2007-07-12 20:30 UTC Modified: 2007-07-14 21:59 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: alex__rider at hotmail dot com Assigned:
Status: Closed Package: Apache2 related
PHP Version: 5.2.3 OS: WinXP
Private report: No CVE-ID: None
 [2007-07-12 20:30 UTC] alex__rider at hotmail dot com
Description:
------------
When trying to set a cookie in PHP under Apache2 / winXP, the cookie is not set.

Reproduce code:
---------------
<?php
setcookie('test','some text', time()+360);
echo 'cookie set<br>';
if (isset($_COOKIE['test']))
{
echo 'cookie retrieved';
}
else
{
echo 'cookie failed';
}
?>

Expected result:
----------------
The out put should read 'cookie retrieved' if the cookie was set

Actual result:
--------------
the output I get is the failed message

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-12 20:36 UTC] jani@php.net
Do you mean it never get set even if you reload the page?
 [2007-07-13 21:27 UTC] alex__rider at hotmail dot com
The cookie is never set even with page reloads, my browser is set to allow cookies, and there is no cookie set when I look at set cookies. I have tried reinstalling both php and apache with no luck.
 [2007-07-14 09:06 UTC] jani@php.net
Check the headers PHP sends for that page.(with e.g. Firebug)
 [2007-07-14 10:26 UTC] alex__rider at hotmail dot com
These are the headers that firebug gives me:

Response Headers
Date	Sat, 14 Jul 2007 10:21:10 GMT
Server	Apache/2.2.4 (Win32) PHP/5.2.4-dev
X-Powered-By	PHP/5.2.4-dev
Keep-Alive	timeout=5, max=99
Connection	Keep-Alive
Content-Type	text/html
Transfer-Encoding	chunked

Request Headers
Host	localhost
User-Agent	Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept	text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language	en-gb,en;q=0.5
Accept-Encoding	gzip,deflate
Accept-Charset	ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive	300
Connection	keep-alive
Referer	http://localhost/test/
 [2007-07-14 10:55 UTC] jani@php.net
How exactly have you setup PHP in apache? Are there some special modules enabled in Apache? I can't reproduce this at all..
 [2007-07-14 11:08 UTC] alex__rider at hotmail dot com
I have installed apache2 from the windows installer on the site, and installed php5 from the windows installer, added the relevant bits into the httpd.conf file

PHPIniDir "K:\apps\PHP\"
LoadModule php5_module "K:\apps\PHP\\php5apache2_2.dll"

ScriptAlias /php/ "K:/Apps/PHP"
AddType application/x-httpd-php .php .php5
Action application/x-httpd-php "K:/Apps/PHP/php.exe"

the only extra module I have installed is php mysql
 [2007-07-14 11:09 UTC] jani@php.net
Try remove that last "Action" entry from httpd.conf..
 [2007-07-14 11:32 UTC] alex__rider at hotmail dot com
I removed the last 'action' form the httpd.conf file and restarted apache, php works but I still get the same problem, the cookie is still not set.
 [2007-07-14 20:52 UTC] jani@php.net
You have done some sort of installation error somewhere.
I tried myself on completely clean machine and installed both Apache and PHP using their installers and just used the default options for everything. (selected the Apache 2.2 module in PHP installer!)

Setting cookies works just fine here. 

Please ask further support questions elsewhere.
You can find support resources at: 

http://www.php.net/support.php
 [2007-07-14 20:53 UTC] jani@php.net
Note: I didn't have to edit any configuration file at all to get Apache+PHP running..
 [2007-07-14 21:59 UTC] alex__rider at hotmail dot com
Thanks for the help you gave.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 01 20:05:53 2022 UTC