Gayner Posted November 30, 2009 Share Posted November 30, 2009 I need $_SESSION{'username'} to be like this: if $_SESSION['username'] = "gayner,bob,jesus"; echo "ba blah "; but do i use Arrays or what for those 3 nameS? how thx Quote Link to comment Share on other sites More sharing options...
trq Posted November 30, 2009 Share Posted November 30, 2009 Your question is about as clear as mud. You can if you like store a string.... $_SESSION['username'] = "gayner,bob,jesus"; or an array..... $_SESSION['username'] = array("gayner","bob","jesus"); Its up to you. Quote Link to comment Share on other sites More sharing options...
zeodragonzord Posted November 30, 2009 Share Posted November 30, 2009 Your goal is to check if the user in the session is either "gayner" "bob" or "jesus" correct? If so, you'll want to do this. $ALLOWED = array("gayner","bob","jesus"); if(in_array($_SESSION['username'], $ALLOWED)) { //do something here } See in_array(needle, haystack): http://php.net/manual/en/function.in-array.php Quote Link to comment Share on other sites More sharing options...
Gayner Posted November 30, 2009 Author Share Posted November 30, 2009 Your goal is to check if the user in the session is either "gayner" "bob" or "jesus" correct? If so, you'll want to do this. $ALLOWED = array("gayner","bob","jesus"); if(in_array($_SESSION['username'], $ALLOWED)) { //do something here } See in_array(needle, haystack): http://php.net/manual/en/function.in-array.php That's what i wanted, thank u sir iuno why guy posted other code toc onfuse me? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.