#37653 [Opn->Bgs]: Cookie Accessing..

From: Date: Wed, 31 May 2006 15:25:56 +0000
Subject: #37653 [Opn->Bgs]: Cookie Accessing..
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97863@lists.php.net to get a copy of this message
ID: 37653 Updated by: tony2001@php.net Reported By: werty37 at gmail dot com -Status: Open +Status: Bogus Bug Type: Output Control Operating System: Linux 2.6.15.23 (Ubuntu Dapper) PHP Version: 5.1.4 New Comment: >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. Previous Comments: ------------------------------------------------------------------------ [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 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" ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37653&edit=1

« previous php.bugs (#97863) next »