note 22977 added to function.session-register

From: Date: Fri, 05 Jul 2002 20:20:06 +0000
Subject: note 22977 added to function.session-register
Groups: php.notes 
Request: Send a blank email to php-notes+get-32646@lists.php.net to get a copy of this message
CAUTION!!!!! CAUTION!!!!! CAUTION!!!!! The PHP.net document failed to mentioned that numeric value is not support for the $_SESSION and never will be. It took me almost a week to find that out. It would have been nice if the documentation mentioned that. I found out about that when I looked up on PHP bug #17122. Demo #1 don't work, Demo #2 work! I'm posting this for your convience and to help you all from making the same mistake one day. --clip-- Demo #1 -------------- //-------Page 1--------- define(CUSTOMER_ID,0); define(CUSTOMER_NAME,1); define(STREET,4); define(CITY,5); define(STATE,6); define(ZIP_CODE,7); $salt = strtoupper(md5(uniqid(rand()))); session_id($salt); session_start(); //$result is from odbc_exec odbc_fetch_into($result,$_SESSION,1); //Example #1 print_r($_SESSION); //This one work!! (Numeric Value) //Example #2 echo $_SESSION[0]; //This one work also! (Numberic Value) //Example #3 echo $_SESSION[CUSTOMER_ID]; //This one work also! (Numeric Value) //-------Page 2--------- session_start(); print_r($_SESSION); //This one does not work! echo $_SESSION[0]; //This one does not work! echo $_SESSION[CUSTOMER_ID]; //This one does not work! //####################### Demo #2 -------------- function session_array_fillitup($result) { $_SESSION[CUSTOMER_ID] = odbc_result($result,1); $_SESSION[CUSTOMER_NAME] = odbc_result($result,2); $_SESSION[STREET] = odbc_result($result,5); $_SESSION[CITY] = odbc_result($result,6); $_SESSION[STATE] = odbc_result($result,7); $_SESSION[ZIP] = odbc_result($result,8); } $salt = strtoupper(md5(uniqid(rand()))); session_id($salt); session_start(); //$result is from odbc_exec session_array_fillitup($result); //-------Page 2--------- session_start(); print_r($_SESSION); //This one work! echo $_SESSION[CUSTOMER_ID]; //This one work! -- http://www.php.net/manual/en/function.session-register.php http://master.php.net/manage/user-notes.php?action=edit+22977 http://master.php.net/manage/user-notes.php?action=delete+22977 http://master.php.net/manage/user-notes.php?action=reject+22977

« previous php.notes (#32646) next »