From: design at laneforestproducts dot com
Operating system: Windows 2000
PHP version: 5.0.0b3 (beta3)
PHP Bug Type: *General Issues
Bug description: Can't Read Cookie From Class Constructor
Description:
------------
With the code below, the expected function is that a returning user with
the 'lfp_guid' cookie will be recognized when the cookie is read. However,
the lfp_guid is never found again after creation and a new lfp_guid is
created at the beginning of each session.
Reproduce code:
---------------
class lfp_user {
var $guid;
function lfp_user() {
if (isset($_COOKIE['lfp_guid'])) {
$this->guid =$_COOKIE['lfp_guid'];
} else {
$this->guid = md5(uniqid(rand(0,1)*100,true));
setcookie("lfp_guid",$this->guid,time()+60*60*24*365*2,"","127.0.0.1",true);
}
echo "LFP_USER.constructor: _COOKIE['lfp_guid']==
'".$_COOKIE['lfp_guid']."'<br>";
echo "LFP_USER.constructor: GUID == ".$this->guid."<br>";
//echo isset($_COOKIE['lfp_guid'])."<br>";
} // end constructor
} // end class
session_start();
if (empty($_COOKIE['PHPSESSID'])) {
$_SESSION['lfp_user'] = new lfp_user();
}
// kill session and reload page again to see nothing in cookie:
print_r($_COOKIE);
Expected result:
----------------
Since the lfp_guid cookie is actually set on the user's machine, $_COOKIE
would access this list and store it in the new object.
Actual result:
--------------
A new lfp_guid is created and set on the user's machine no matter what.
--
Edit bug report at http://bugs.php.net/?id=27050&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27050&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27050&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27050&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27050&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27050&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27050&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27050&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27050&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27050&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27050&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27050&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27050&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27050&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27050&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27050&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27050&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27050&r=float