Jump to content

[SOLVED] SESSION problems


Cenron

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/56876-solved-session-problems/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.