|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 11:00:01 2025 UTC |
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