So from my existing code, I can tell that on some occasions the code grabs the users ID with a) <?if($comments[$i]['uid'] == user_id){?> - user_id in this case is what I need b) $_SESSION[user][id] But the problem is that none of these work when I display them in other parts of the code. Basically the session user ID here is the number of the registered user (when logged in) in my database And I need to grab that number. Perhaps I wasn't displaying a) right? I tried $user_id, 'user_id' in echo's, didn't work. I can't believe how helpful this forum has been to me and really appreciate all the help from you guys. You're the best.
try 1) print $_SESSION['userid']; 2) print_r($_SESSION); //this one will print an array with every values of session
Whoah, that helped. I don't know why, but echo didn't display $_SESSION['id'] - but this one did and I found the [id] variable through the second print Very helpful (for google) If you want to display all of your sessions, print_r($_SESSION); Thanks a lot man, I hope this helps others
Ok, this is weird It was working fine, but after I logged in from another computer, it just vanished. print_r($_SESSION); still displays what I need but print $_SESSION['id'] doesn't work anymore wtf? 0_o
I'm not sure, please check what's it value into print_r array If not, double check things I dont know, try logging with different username on other computer, and put an error_reporting(E_ALL); line to showup errors
Strange. So at first it worked through $_SESSION[id] Then it stopped working. But now it works through the initial $_SESSION[user][id] I have no idea how that worked out, but at least it works
Wild guess - different $_SESSION-ids for admins, moderators, user etc.? Dunno if that might be a solution...
I think that bug occured because I've logged in from another computer on the same network (IP). My website checks both IPs and Cookies. IPs were a match, cookies weren't, so it kind of messed itself up for some odd reason. But adding [user] to the mix fixed it. Although I didn't bother with cross-browser testing. Screw IE. If my users don't use FF, they can go die xD
Try storing the session ID as 'loggedin' and add a value of 1 to the field in the db, and calling the user id from where the user is logged in. GET_$userid WHERE $userloggedin = 1