PHP Session issues

software development

#1

I have an login script wich is working great in localhost but it is not working at all on-line.
No errors, nothing, the session vars just don’t get registered.

Has anyone have/had this issues before?


#2

You’ll need to supply your source to get a decent response.

Could be this: http://wiki.dreamhost.com/Register_globals

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#3

Yes, sorry for that, don’t think it’s register_globals or register_long_arrays.

Here’s the login:

[code]<?php
// session already started.
if (isset($_SESSION[‘uname’])) {
$username = $_SESSION[‘uname’];
$check_user = $db->query(“SELECT * FROM users WHERE uname = ‘$username’”);
while ($user = mysql_fetch_array($check_user)) {
echo ‘Welcome ‘.$user[“name”].’ ‘.$user[“lname”].’ - ‘.get_row(‘type’, ‘users’, ‘uname’, $username).’ | Log-out’;
}
} else {
// FORM HERE.
?>

<?php } ?>[/code]

Here is the log-in checker:

<?php include_once ('../../conf.php'); include_once ('../../class.db.php'); include_once ('../../func.php'); $uname = clean($_POST ['uname']); $pass = clean(sha1($_POST ['pass'])); $check_user = $db->query ( "SELECT * FROM `users` WHERE `uname` = '$uname' AND `sha1` = '$pass'" ); $count = mysql_num_rows ( $check_user ); if ($count == 1) { session_start (); $_SESSION['uname'] = $user ['uname']; $_SESSION['name'] = $user ['name']; $_SESSION['lname'] = $user ['lname']; attention("Welcome !",'ok',2); } else { attention('Errors !','error',2); } ob_end_flush (); ?>
Here’s get_row():

function get_row($what, $table, $where_row, $where_is) { $db = new db(); $r = $db->query("SELECT `$what` FROM `$table` WHERE `$where_row` = '$where_is'"); $row = mysql_fetch_row($r); return $row[0]; $db->kill($r);
Here’s clean():

function clean($string) { $string = addslashes($string); $string = htmlentities($string); $string = strip_tags($string); return $string;
Here’s class db:

[code]<?php
require_once(‘conf.php’);
class db {
var $host;
var $user;
var $pass;
var $name;
var $db_link;
var $db;

function __construct() {
$this->host = _dbhost;
$this->user = _dbuser;
$this->pass = _dbpass;
$this->name = _dbname;
}
function query($sql) {
$db_link = @mysql_connect ( $this->host, $this->user, $this->pass ) or die ( 'Connection ERROR: ’ . mysql_errno () . ’ ’ . mysql_error () );
$select = @mysql_select_db ( $this->name, $db_link ) or die ( 'DB ERROR: ’ . mysql_errno () . ’ ’ . mysql_error () );
$query .= mysql_query ( “SET character_set_client=utf8” );
$query .= mysql_query ( “SET character_set_connection=utf8” );
$query .= mysql_query ( “SET character_set_database=utf8” );
$query .= mysql_query ( “SET character_set_results=utf8” );
$query .= mysql_query ( “SET character_set_server=utf8” );
$query = mysql_query ( $sql, $db_link ) or die ( 'Query ERROR: ’ . mysql_errno () . ’ ’ . mysql_error () );
$this->kill();
return $query;
}
function kill($db_link)
{
@mysql_close($db_link);
}
function num_rows($table)
{
$r = $db->query(“SELECT COUNT(*) FROM ‘$table’”);
$rows = mysql_num_rows($r);
echo $rows;
}
}
$db = new db();
?>
[/code]