I've got this error
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/siambidd/domains/siambidding.com/public_html/session.php:3) in /home/siambidd/domains/siambidding.com/public_html/session.php on line 4

I've checked my code, there is no any spaces,
and I'm not using BOM as well, but still got this error.
please help me
here is my code

<html>
<head>
<?php
session_start();
ob_start();
include('connection.php');
$username = $_POST['username'];
$password = $_POST['password'];
$remember = $_POST['remember'];
$sql = ("SELECT * FROM users WHERE username='$username'");
$result = mysql_query($sql);
if ($result)
{
    $rows = mysql_fetch_array($result);
    $passwordx = $rows['password'];
    if ($password == $passwordx)
    {
        $_SESSION[ses_id] = session_id();
        $_SESSION[ses_username] = $username;

        echo "<meta http-equiv='refresh' content='0;url=session.php'>";
    }
    else
    {    
        echo "รหัสผ่านไม่ถูกต้อง";
    }
}
else
{
    echo "ไม่พบ username นี้ใระบบ";
}
?>
</head>
<body>
</body>
</html>

session_start() must be the first statement....
So just remove it and place it at top...

<?php
session_start();
?>
<html>
<head>
<?php

ob_start();
include('connection.php');
$username = $_POST['username'];
$password = $_POST['password'];
$remember = $_POST['remember'];
$sql = ("SELECT * FROM users WHERE username='$username'");
$result = mysql_query($sql);
if ($result)
{
$rows = mysql_fetch_array($result);
$passwordx = $rows['password'];
if ($password == $passwordx)
{
$_SESSION[ses_id] = session_id();
$_SESSION[ses_username] = $username;

echo "<meta http-equiv='refresh' content='0;url=session.php'>";
}
else
{ 
echo "รหัสผ่านไม่ถูกต้อง";
}
}
else
{
echo "ไม่พบ username นี้ใระบบ";
}
?>
</head>
<body>
</body>
</html>

PS-If your problem is solved mark the thread as solved

I've tried it, and it didn't work.
I've tried ob_start() as well, it just got the same error.

<?php
session_start();
include('connection.php');
$username = $_POST;
$password = $_POST;
$remember = $_POST;
$sql = ("SELECT * FROM users WHERE username='$username'");
$result = mysql_query($sql);
if ($result){
$rows = mysql_fetch_array($result);
$passwordx = $rows;
if ($password == $passwordx){
$_SESSION[ses_id] = session_id();
$_SESSION[ses_username] = $username;

echo "<meta http-equiv='refresh' content='0;url=session.php'>";
} else {
echo "รหัสผ่านไม่ถูกต้อง";
}
} else {
echo "ไม่พบ username นี้ใระบบ";
}
?>
<html>
<head>
</head>
<body>
</body>
</html>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.