[PHP / MySQL] Hmm, Cookies

I got this problem here, im not sure if it should be like that, or that I do something wrong.

The main question is rather simple ( cant find the answer though ):

Can setcookie() use variables as input?

And if so, why doesnt the following work?

Explanation of the code:

This script is part of a login system, its one of my first, so its rather simple. The idea behind it is that the database contains three collumns: user, password and access.
Once the user is present and the password matches the filled in value the script places a cookie with the acces number you have ( for example, 9 is admin ).
The cookie expires as soon as the session ends. Now the issue is that instead of the wanted 9 that belongs to the user in the database, the output of the cookie is: $access, and so after I log in the screen tells me: No Acces to Index Mode.
Can someone please tell me the issue and maybe a solution?


/* Security Check */

$accesset = isset($_COOKIE["acces"]);
 
 if ($accesset == TRUE) // Checks if the cookie is set
 { echo "Acces is Set<br>"; }
 /* Tracer, as soon as the cookie is set, and the page refreshes this will appear */
 else{ 
  
     $result = mysql_query("SELECT * FROM userdb WHERE user = '$user'") or die("Query Failed - 1");
     $usercheck = mysql_num_rows($result); // If the user is found return 1
     
     if ( $usercheck == 1 )
     {
        $passcheck = mysql_query("SELECT password FROM userdb WHERE user = '$user'") or die("Query Failed - 2");
        list ($passcheck) = mysql_fetch_array ($passcheck); 
// List, to avoid Resourse id #5
        $password = md5($password);
        if ( $passcheck == $password )
        {
            $accesquery = mysql_query("SELECT access FROM userdb WHERE user = '$user'") or die("Query Failed - 3");
//A small loop to put the returned content in the var
while ($row = mysql_fetch_array($accesquery)) { 
            $access        = $row["access"];
            }
            //list ($acces) = mysql_fetch_array ($acces); 
            setcookie('access', '$access'); // Simple cookie set
            header('Location:index.php'); // Refreshes page
        }
        else
        {
         header('Location:login.php');
        }
     }
     else { header('Location:login.php'); }
 }
 
 /* Index Mode */
 
 if ($acces == 9)
 {
     echo "<br>Your Index Mode acces level is: $acces";
 }
 else
 {
     echo "<br>No Acces to Index Mode";
 }

Thanks in advance,

Hyper