Hello all,
I need to send sesiion ID via cookies insted of url. How do i do that and how do I recall the content of cookie from a different page?
Here is my code. What i am trying to do is to login users and then verify that the user is a valid user to access the page. If the user is not validated he is redirected to the logon page.
+++++++++++++++++++++++++++++++++++++++++++++
session_start();
session_register("auth");
$auth = false; // Assume user is not authenticated
if ($username != "" && $password != "") {
// Connect to MSSQL
mssql_connect( 'SQL2K')
or die ( 'Unable to connect to server.' );
// Select database on MSSQL server
mssql_select_db( 'table_name' )
or die ( 'Unable to select database.' );
// Formulate the query
$sql = "SELECT * FROM WEB_Access_Verification WHERE
username = '$username'";
// Execute the query and put results in $result
$result = mssql_query( $sql )
or die ( 'Unable to execute query.' );
// Get number of rows in $result.
$num = mSsql_num_rows( $result );
if ( $num != 0 ) {
// A matching row was found - the user is authenticated.
$result0 = mssql_result( $result, 0, realpassword )
or die ( 'Unable to get result. ');
if ( $result0 != $password){
// session_register($auth);
$auth = false;
} else {
//session_register($auth);
$auth = true;
}
}
}
//$sessionid = session_id();
if ( ! $auth ) {
header('Location: http://www.domainname.com/error_index2.php' );
exit;
} else {
header('Location: http://www.domainname.com/ok.php?'.sid );
}
?>
+++++++++++++++++++++++++++++++++++++++++++++
SECOND page initial check code
+++++++++++++++++++++++++++++++++++++++++++++
session_start();
if (! $auth ) {
header('Location: http://www.domainname.com/error_index2.php' );
exit;
}
?>