In php, the session problem isset () cannot judge login. php & lt ;? Phpsession_start (); include_once 'fuctions. php '; $ account =$ _ REQUEST [& quot; account & quot;]; & nbsp; $ password =$ _ REQ: The session problem isset () in php cannot be determined.
Login. php
Session_start ();
Include_once 'fuctions. php ';
$ Account = $ _ REQUEST ["account"];
$ Password = $ _ REQUEST ["password"];
$ Con = connectDB ();
$ Query = "select * from im where account = '". $ account. "' and password = '". $ password ."';";
$ Result = mysql_query ($ query );
If ($ row = mysql_fetch_array ($ result )){
Echo ("true ");
$ _ SESSION ['$ row ["id"]'] = true;
}
Else {
Echo ("false ");
}
Mysql_close ($ con );
?>
Contact. php
Session_start ();
Include_once 'fuctions. php ';
$ Con = connectDB ();
$ Query = "select * from im ";
$ Result = mysql_query ($ query );
$ Count = 0;
While ($ row = mysql_fetch_array ($ result )){
$ Contact [$ count] = array ("id" => $ row ["id"], "name" => $ row ["name"], "group" => $ row ["group"], "phone" => $ row ["phone"], "online" => 1 );
$ Count ++;
}
For ($ I = 0; $ I <$ count; $ I ++ ){
If (! Isset ($ _ SESSION ['$ contact [$ I] ["id"]']) {
$ Contact [$ I] ["online"] = 0;
}
}
Foreach ($ contact as $ key => $ array ){
If (is_array ($ array )){
Foreach ($ array as $ key => $ value ){
Echo ($ key. "=>". $ value ."");
}
}
}
$ Json = array ();
For ($ I = 0; $ I <$ count; $ I ++ ){
["Group"], "phone" => $ contact [$ I] ["phone"]);
}
Mysql_close ($ con );
?>
Why can't I judge every isset ($ _ SESSION ['$ contact [$ I] ["id?
------ Solution --------------------
C/C ++ code
[User: root Time: 12: 01: 13 Path:/home/liangdong/php] $ php dot. php Array ([$ B] => 1) [User: root Time: 12: 01: 16 Path:/home/liangdong/php] $ cat dot. php
[User: root Time: 12: 01: 18 Path:/home/liangdong/php] $
------ Solution --------------------
Set
$ _ SESSION ['$ row ["id"]'] = true; and isset ($ _ SESSION ['$ contact [$ I] ["id"]'])
Change
$ _ SESSION ["$ row ['id']"] = true; and isset ($ _ SESSION ["$ contact [$ I] ['id']"])
The quotation marks are reversed. This IDE will prompt you.
------ Solution --------------------
If (! Isset ($ _ SESSION [$ contact [$ I] ["id"]) {
$ Contact [$ I] ["online"] = 0;
}
Remove the unlucky pair of single quotes
------ Solution --------------------
$ _ SESSION [$ row ['id'] = true;
No quotation marks are required for the key values in the array.