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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.