Click to See Complete Forum and Search --> : Need help with User login session


predhtz
04-04-2005, 03:36 AM
I got some problem with login system using PHP and SQL 2000 server.
The session registered on login php cannot be read by authenticated pages like index.php...
i use code like this :

login php :

session_start();
include_once "inc/config.php";
$username = $_REQUEST["username"];
$password = crypt($_REQUEST["password"]);

$conn = new COM("ADODB.Connection") or die("Cannot start ADO");
$conn->Open("Provider=SQLOLEDB; Data Source=localhost; Initial Catalog=database; User ID=dbuid; Password=dbpwd");
$rs = $conn->Execute("SELECT * FROM administrator");
if ($rs->fields["username"]==$username || $rs->fields["password"]==$password){
while (!$rs->EOF){
$adminid = $rs->fields["id"];
session_start();
session_register ("id");
$session_adminid=$id;
$_SESSION["id"];

header("location: index.php");
}
else {
// login form
}

and the code of index.php :

session_start();
if (!isset($_SESSION["id"])){
header("location: login.php");
}
else {
ob_start();
//index_page_content
}

can someone help me??

bradgrafelman
04-04-2005, 09:04 PM
Wouldn't this be a better post for the Coding Forum (http://www.phpbuilder.com/board/forumdisplay.php?s=&forumid=10) ? (Maybe a Mod will move it for you)

Also: maybe you should set a session_name OR pass the SID in the URL, so PHP knows what session to open (info on that at the session_start manual entry)