doforumda Posted May 21, 2011 Share Posted May 21, 2011 Hi I am using very simple code. Here it is <?php session_start(); $user = "guest"; $uid = "1"; echo $_SESSION['user']."<br />"; echo $_SESSION['uid']; ?> it displays this error Notice: Undefined index: user in C:\wamp\www\DealDash\index.php on line 5 Notice: Undefined index: uid in C:\wamp\www\DealDash\index.php on line 6 how can I solve this problem? Help please Link to comment https://forums.phpfreaks.com/topic/237058-help-with-session-variable/ Share on other sites More sharing options...
PFMaBiSmAd Posted May 21, 2011 Share Posted May 21, 2011 <?php session_start(); $_SESSION['user'] = "guest"; $_SESSION['uid'] = "1"; echo $_SESSION['user']."<br />"; echo $_SESSION['uid']; ?> Link to comment https://forums.phpfreaks.com/topic/237058-help-with-session-variable/#findComment-1218469 Share on other sites More sharing options...
Genesis730 Posted May 21, 2011 Share Posted May 21, 2011 It's giving you an error for anytime you use a variable that hasn't been inialized yet. To stop that, just post this BEFORE the error (I.E. the variables are used) <?php error_reporting(E_ALL ^ E_NOTICE); ?> Link to comment https://forums.phpfreaks.com/topic/237058-help-with-session-variable/#findComment-1218473 Share on other sites More sharing options...
Pikachu2000 Posted May 21, 2011 Share Posted May 21, 2011 To stop the warning, fix the condition that is causing the warning in the first place. Link to comment https://forums.phpfreaks.com/topic/237058-help-with-session-variable/#findComment-1218474 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.