Cenron Posted June 23, 2007 Share Posted June 23, 2007 Hey guys I am having a problem I am trying to make a permission system for my website and its not working right. The permissions are working find but my sessions dont seem to want to hold the data when a user logs into the site it finds him in the database does a mysql_fetch_array and puts the info into the session function login_user() { session_start(); $row = mysql_fetch_array($result); $_SESSION = $row; } login_user(); Little bit down the code; ... ... $perm =$GROUP->get_perm($_SESSION['group_id'],$DB->sqlGetResource()); Now the problem is it dosent fill in $_SESSION until after you hit refresh...so after you hit login it dosent have anything in the session but when you hit refresh again its loaded. I am having a hard time getting around this. Quote Link to comment Share on other sites More sharing options...
lewis987 Posted June 23, 2007 Share Posted June 23, 2007 arent you meant to fulfil the name of the session? instead of: $_SESSION = $row; shouldnt it be: $_SESSION['NAME_OF_SESSION'] = $row['NAME_OF_COLUMN'] Quote Link to comment Share on other sites More sharing options...
bluebyyou Posted June 23, 2007 Share Posted June 23, 2007 Can you post more of the code, like where you query the db to get the $result or what are the colums in the db? Quote Link to comment Share on other sites More sharing options...
Cenron Posted June 24, 2007 Author Share Posted June 24, 2007 Basicly this is how it works [i]user_class.php[/i] function login_user() { session_start(); get_cookie(); $id= get_id(); $result = mysql_query("SELECT * FROM `users` WHERE `id` = $id"); $row = mysql_fetch_array($result); if(!$row) { return 0; } if($_COOKIE['pass'] != $row['pass']) { return 0; } unset($_SESSION); $_SESSION = $row; @mysql_query("UPDATE `users` SET `last_logged` = NOW(), `ip`='$ip' WHERE `id` = '$id'"); $this->set_cookies($row['id'], $row['pass']); return 1; } Then its gets called from [i]functions.php[/i] include(ALL_MY_INCLUDES); $DB = &new cSQL; $USER = &new cUSER; $DB->sqlConnect($dbhost,$dbuser,$dbpass); $DB->sqlSelectDb($dbdatabase); $USER->login_user(); ..... ..... Main Header Function() { } .... .... $perm =$GROUP->get_perm($_SESSION['group_id'],$DB->sqlGetResource()); Thats just the basic summery 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.