php - $_GET index isset -


this url :

http://localhost/messources/actes/palactes.php?mode=mode_new 

in php have :

if (isset($_get['id']))             {                 $_session['id'] = $_get['id'];             }else{                 $_session['id'] = $_session['id'];             } 

since id not in url, expect entire block not executed. $_get['id'] doesn't exist, value should null therefore isset() testing that.

however, php notice :

undefined index: id in .... 

what should rid of notice (i don't want add &id= url)

use

 session_start();// if havent started.  if (isset($_get['id']))             {                 $_session['id'] = $_get['id'];             }else{                 $_session['id'] = 0;             } 

and can check if 0 or not . if 0 then, not logged in else logged in.


Comments