Dear Sir/Madam,

I've been trying out my script, it works fine so far on my pc with apache
1.3.26 with php 4.3.0

but when i uploaded to another server with
http://www.mercstudio.com/test.php

the session seems to be unstable.
sometimes it works, sometimes not.

http://www.mercstudio.com/hoteldemo/myadmin/

when i set the session key called "userkey"
it works fine on my pc.
but when i upload them on the server, some pc r able to login, but most of
the pc did not get to login.

the login check with mysql database went fine, but the session did not set
on some pc attempting to login

index.php -> login.php (set userkey=1) -> main.php (check session userkey >
0)

if session userkey is not set, the user will be brought back to index.php


here's my login code:

==============login.php==================
include "lib/mysql.php";
include "lib/u007lib.php";

// connecting to mysql db , my own lib...
$rs = getdb("");
$rs->query("select * from ct_user where companyid like '" .
$HTTP_POST_VARS["companyid"] .  "'");
$rs2 = getdb("");

$erron = "";

if(!$rs->eof)
{

// if company records found...
$rs2->query("select * from ct_login where loginid like '" .
$HTTP_POST_VARS["loginid"] . "' and userid=" . $rs->fields("id") . " and
pass like '" . $HTTP_POST_VARS["password"] . "'");

if(!$rs2->eof)
{
// if loginid and password match...

session_start();
// session key to be checked...
$userkey = $rs2->fields("lvl");

$userid = $rs2->fields("id");
$userloginid = $rs2->fields("loginid");

$usercomid = $rs->fields("id");
$usercompany = $rs->fields("company");
$usercompanyid = $rs->fields("companyid");

// registering session key
session_register("userkey");
session_register("usercomid");
session_register("usercompany");
session_register("usercompanyid");

session_register("userid");
session_register("userloginid");


setcookie("companyid", $HTTP_POST_VARS["companyid"], time()+(60*60*24*30));
setcookie("loginid", $HTTP_POST_VARS["loginid"], time()+(60*60*24*30));

//redirecting to main.php
header("location: main.php"); exit();
}
else
{
$erron = "Invalid User / Password";
}

}
else
{
$erron = "No Such Company ID";
}

?>
=============end of login code========================

=============beginning code of main.php=================
<?
session_start();
include "lib/u007lib.php";
include "lib/mysql.php";

// check session userkey
if($HTTP_SESSION_VARS["userkey"]-0 < 1) { header("location: ./"); return; }
?>
==============end of main.php code=====================

please advise,

thank you

--
James Tan
IT Technical Specialist

NextMove Technology Sdn. Bhd.
Tel: 03-5192 1366
Fax: 03-5192 1280
Lot 2-2, Jalan SU6A,
Persiaran Tengku Ampuan,
Lion Industrial Park, Section 22,
40000 Shah Alam, Selangor D.E.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to