#37653 [Bgs->Opn]: Cookie Accessing..
| From: | werty37 at gmail dot com | Date: | Wed, 31 May 2006 15:30:41 +0000 |
| Subject: | #37653 [Bgs->Opn]: Cookie Accessing.. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-97864@lists.php.net to get a copy of this message | ||
ID: 37653
User updated by: werty37 at gmail dot com
Reported By: werty37 at gmail dot com
-Status: Bogus
+Status: Open
Bug Type: Output Control
Operating System: Linux 2.6.15.23 (Ubuntu Dapper)
PHP Version: 5.1.4
New Comment:
But i ve send a white space already
<?php ob_start('ob_gzhandler');
if (!isset($_COOKIE['RESULTS']))
{
session_name('RESULTS');
session_set_cookie_params(3600, "/", "", 0);
session_start();
}
ob_flush();
?>
^^^^^^^^^^^^^^^^^here...
<?php
if (!isset($_COOKIE['RESULTS'])) { die("Cookies are disabled");} else
{echo $_COOKIE['RESULTS'];}
?>
So that means i ve send the headers too, right
Previous Comments:
------------------------------------------------------------------------
[2006-05-31 15:25:56] tony2001@php.net
>it won’t be set on the client until that page (and its HTTP
> headers) are sent off to the client.
Wrong. They won't be set until the client sent them back.
------------------------------------------------------------------------
[2006-05-31 15:16:45] werty37 at gmail dot com
Description:
------------
Hi
I think there is some problem with cookie accessing.
I am using PHP Version 5.1.2, Apache 2.
The first time i request the web page, i
get the message "Cookies are disabled". On the second request and
subquent requests, the script prints the cookie content.
I know that if a cookie is set in a given script, it wont be set on
the client until that page (and its HTTP headers) are sent off to the
client.
But in my script im explicitly flushing the headers.
Please correct me if i am wrong.
Reproduce code:
---------------
<?php ob_start('ob_gzhandler');
if (!isset($_COOKIE['RESULTS']))
{
session_name('RESULTS');
session_set_cookie_params(3600, "/", "", 0);
session_start();
}
ob_flush();
?>
<?php
if (!isset($_COOKIE['RESULTS'])) { die("Cookies are disabled");} else
{echo $_COOKIE['RESULTS'];}
?>
Expected result:
----------------
if cookies are enabled by the user, on first request
it should print the cookie content.
if cookies are disabled, it should print "Cookies
are disabled"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37653&edit=1