Hmm, it won't recognize me when the browser is restarted:
Check.php:
PHP Code:
<?php
if(isset($_COOKIE['BSComputersU']) && isset($_COOKIE['BSComputersP'])){
header("Location: iscookie.php");
}
include(
'config.php');
// connect to the mysql database server.
mysql_connect ($dbhost$dbusername$dbuserpass);
mysql_select_db($dbname) or die('Cannot select database');
if (
$_POST['username']) {
//did they supply a password and username
$username=$_POST['username'];
$password=$_POST['password'];
if (
$password==NULL) {
echo 
"<center>Du har ikke indtastet et kodeord!</center><br>
<center>
<h1>Login</h1>
<form action='check.php' method='POST'>
<table style='border:1px solid #000000;'>
<tr>
<td align='right'>
Brugernavn: <input type='text' size='15' maxlength='25' name='username'>
</td>
</tr>
<tr>
<td align='right'>
Kodeord: <input type='password' size='15' maxlength='25' name='password'>
</td>
</tr>
<tr>
<td align='center'>
<input type='submit' value='Login'>
</td>
</tr>
<tr>
<td align='center'>
<a href='register.php'>Opret bruger her</a>
</td>
</tr>
</table>
</form></center>
"
;
}else{
$query mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$data mysql_fetch_array($query);
if(
$data['password'] != md5($password)) {
echo 
"<center>Du har indtastet forkert brugernavn eller kodeord! Prøv igen<br><center>
<h1>Login</h1>
<form action='check.php' method='POST'>
<table style='border:1px solid #000000;'>
<tr>
<td align='right'>
Brugernavn: <input type='text' size='15' maxlength='25' name='username'>
</td>
</tr>
<tr>
<td align='right'>
Kodeord: <input type='password' size='15' maxlength='25' name='password'>
</td>
</tr>
<tr>
<td align='center'>
<input type='submit' value='Login'>
</td>
</tr>
<tr>
<td align='center'>
<a href='register.php'>Opret bruger her</a>
</td>
</tr>
</table>
</form></center>
</center>"
;
}else{
if (isset(
$_POST['husklogin']) && (bool)$_POST['husklogin']) {
  
setcookie('BSComputersU'$usernametime() + 3600 24 365);
  
setcookie('BSComputersP'md5($password), time() + 3600 24 365);
}
$query mysql_query("SELECT username,password FROM users WHERE username = '$username'") or die(mysql_error());
$row mysql_fetch_array($query);
$_SESSION["s_username"] = $row['username'];
header("Location: index.php"); 
}
}
}
?>
<script language="javascript" type="text/javascript">
function createRequestObject()
{
    var request_o; //declare the variable to hold the object.
    var browser = navigator.appName; //find the browser name
    if(browser == "Microsoft Internet Explorer"){
        /* Create the object using MSIE's method */
        request_o = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        /* Create the object using other browser's method */
        request_o = new XMLHttpRequest();
    }
    return request_o; //return the object
}


var http = createRequestObject();
function destorySession()
{
    try
    { 
    http.open('get', 'destroy.php');
    http.send(null);
    }
    catch(Exception)
    {
        http = createRequestObject();
        destorySession();
    }
}

window.onunload = destorySession();
</script>
iscookie.php:
PHP Code:
<?php
  
include('config.php');
  
mysql_connect ($dbhost$dbusername$dbuserpass);
  
mysql_select_db($dbname) or die('Cannot select database');
  if (isset(
$_COOKIE['BSComputersU']) && isset($_COOKIE['BSComputersP'])) {
    
$username $_COOKIE['BSComputersU'];
    
$query mysql_query(
      
'SELECT username,password '.
      
'FROM users WHERE username = \''.$username.'\''
    
);
    if (
mysql_errno())
      echo 
mysql_error();
    
    
$data mysql_fetch_array($query);
    
$password $_COOKIE['BSComputersP'];
    
    if (
$data['password'] != $password) {
      
header('Location: index.php');
    }
    else if(!isset(
$_COOKIE['BSComputersU']) && !isset($_COOKIE['BSComputersP'])){
      
header('Location: index.php');
    }
    else {
      
$query mysql_query(
        
'SELECT username,password '.
        
'FROM users WHERE username = \''.$username.'\''
      
);
      if (
mysql_errno())
        echo 
mysql_error();
      
      
$row mysql_fetch_array($query);
      
$_SESSION['s_username'] = $row['username'];
      
header('Location: index.php');
    }
  }
?>