<?php include 'concha.php';
   session_start();

    // Conexi�n a la base de datos

mysql_select_db ("$basedatos", $Conn) or die(mysql_error());

      $_SESSION['s_username'] = mysql_real_escape_string($_SESSION['s_username']);
      $_SESSION['token'] = mysql_real_escape_string($_SESSION['token']);


	  //checamos que exista
      $query = mysql_query("SELECT * FROM users ".
            "WHERE username = '{$_SESSION['s_username']}' AND ".
            "token = '{$_SESSION['token']}' ");


    if(mysql_num_rows($query) == 1) {
           //volvemos a calcular un token
           $_SESSION['token'] = md5(rand().$_SESSION['s_username']);
           mysql_query("UPDATE users SET ".
           "token = '{$_SESSION['token']}' WHERE ".
           "username = '{$_SESSION['s_username']}' ");

	$user = $_SESSION['s_username'];


}else{

    };

include('concha.php');
mysql_connect ("$host", "$usuario", "$contra");
mysql_select_db ("$basedatos");

$sql = "SELECT * FROM users where username = '$user'";

$consulta = mysql_query ($sql);
while ($row = mysql_fetch_array($consulta))
{
$nombre = $row["nombre"];
$apellido 	= $row['apellido'];
$email = $row['email'];
$cat_user = $row['nivel'];
  }
mysql_free_result($consulta);


?>
