php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37653 Cookie Accessing..
Submitted: 2006-05-31 15:16 UTC Modified: 2006-05-31 15:45 UTC
From: werty37 at gmail dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.1.4 OS: Linux 2.6.15.23 (Ubuntu Dapper)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: werty37 at gmail dot com
New email:
PHP Version: OS:

 

 [2006-05-31 15:16 UTC] 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 won?t 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"


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-31 15:25 UTC] tony2001@php.net
>it won&#8217;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:30 UTC] werty37 at gmail dot com
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
 [2006-05-31 15:36 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 [2006-05-31 15:37 UTC] werty37 at gmail dot com
>
>Wrong. They won't be set until the client sent them back.
>

IS this a feature?

Thanks
 [2006-05-31 15:45 UTC] johannes@php.net
No, thats how cookies work. Please use a support forum and 
the documentation. This place is for reporting bugs.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 19:01:29 2024 UTC