dmhall0 Posted May 4, 2012 Share Posted May 4, 2012 When a user logs into my site I was to store the user_name, user_role, and user_id in a session variable, then store this in a regular variable to make querying easier, but I am having issues with my code as its causing issues with my queries. if (mysqli_num_rows($data) > 0) { //set sessions $row = mysqli_fetch_array($data); $_SESSION['username'] = $row['username']; $_SESSION['user_role'] = $row['role']; $_SESSION['user_id'] = $row['user_id']; //set variables $username = $_SESSION['username']; $user_role = $_SESSION['user_role']; $user_id = $_SESSION['user_id']; } Any ideas whats wrong?! Thanks for the help!! Quote Link to comment https://forums.phpfreaks.com/topic/262086-multiple-_session-variables-issue/ Share on other sites More sharing options...
darkfreaks Posted May 4, 2012 Share Posted May 4, 2012 tr something like this. //looping all rows and setting it as a session foreach($row as $key=>$value) { if(is_string($key)){ //if keys a string set session $_SESSION[$key] = $value; } //echo out the session echo $_SESSION['username']; //should output the session } Quote Link to comment https://forums.phpfreaks.com/topic/262086-multiple-_session-variables-issue/#findComment-1343150 Share on other sites More sharing options...
xyph Posted May 4, 2012 Share Posted May 4, 2012 More details in your error report would help us help you. Causing issues means nothing to anyone besides you. Quote Link to comment https://forums.phpfreaks.com/topic/262086-multiple-_session-variables-issue/#findComment-1343178 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.